Questions tagged [laravel-helper]

Laravel includes a variety of global "helper" PHP functions. Many of these functions are used by the framework itself; however, you are free to use them in your own applications if you find them convenient.

Laravel provides many excellent helper functions that are convenient for doing things like working with arrays, file paths, strings, and routes, among other things like the beloved dd() function.

29 questions
0
votes
1 answer

Laravel - Get queue data before run

I want to send a custom data in my queues and want to catch this data before action running. The best possibility for me would be to send a header value, so I could use getallheaders() to read this data, but I did read and don't found this…
Thiago Valente
  • 673
  • 8
  • 25
0
votes
1 answer

Laravel - Catch php artisan commands

I've did some changes in my config/app to use multiple databases selected by front-end, now I have to tell in \Request()->header('database') which database I want access. It's work perfectly, the problem is: when I try to do any artisan commands my…
0
votes
1 answer

Laravel queue job does not load file in

I am a bit stuck with loading in a file for Laravel Queue/Job I am using Laravel queued/async jobs (lets call it job for easy use) Oke lets start from the beginning, we have our own translation function and we also named it __() just like the…
Niels Lucas
  • 739
  • 1
  • 12
  • 31
0
votes
2 answers

Laravel custom strings helper file

I created an Artisan command file which handles strings in different encodings. I needed to implement a mb_str_pad function (and found this one). I created a helper file app/Library/Helpers/StringHelper.php:
guyaloni
  • 4,972
  • 5
  • 52
  • 92
0
votes
2 answers

How to create a method able for use everywhere in Laravel

I want to make some changes to dates, for example, I want to explode it do some operation and implode it again, and I want to use it all around my app so here is my code : $divided_date = explode('/', $request->point_date); $converted_date =…
Farshad
  • 1,830
  • 6
  • 38
  • 70
0
votes
1 answer

Laravel Helper Set Class Active Not Working

I have a helper function. function setActive($path, $active = 'active') { return call_user_func_array('Request::is', (array)$path) ? $active : ''; } When I go to the site: http://example.net/posts?group=active, my function is not working and…
Dumitru
  • 2,053
  • 6
  • 20
  • 45
0
votes
1 answer

How to Add a Custom Function That Can Be Chained with the Auth() Function?

As stated in the documentation, the auth() function can be used instead of the Auth facade, returns an authenticator instance and can be used like this: auth()->check() auth()->guest() auth()->id() auth()->user() As you can see - I can chain…
PeraMika
  • 3,539
  • 9
  • 38
  • 63
0
votes
4 answers

How to Solve "Trying to get property of non-object" in Laravel?

If my code return null then it generates this error. If the code returns some data, then it works fine. Controller $profile_data= DB::table('partner_prefence') ->select('*') ->where('profile_id',$profile_id) ->first(); return…
Entrepreuner
  • 53
  • 4
  • 11
0
votes
2 answers

Laravel How to get Helper function return value in controller as url path

I have created a laravel helper something like this which generates an sql file in /sql/ under my database folder location so database/sqls/xxxxx.sql class Helpsql { public function cd(string $file = '') { $destinationFile…
Codebugggs
  • 33
  • 1
  • 1
  • 7
0
votes
1 answer

How can I submit an HTML form without the use of HTML helper function

Just using the HTML form, how can I submit a form to a store function in the resource controller, if the route is /register. Please help, I've tried inserting 'post' method in the form tag,it's not working. Meanwhile the name of the store route is…
0
votes
2 answers

Unable to use helper in controller of laravel app

I'm building an application, now i'm created a helper class Students{ public static function return_student_names() { $_only_student_first_name = array('a','b','c'); return $_only_student_first_name; } } now i'm unable…
runningmark
  • 738
  • 4
  • 13
  • 32
-1
votes
1 answer

Keep original string language in laravel slug

With laravel(I am using v.9.x) Str:slug you can convert a string to a slug like: Woman life freedom to Woman-life-freedom but the problem is when you pass a non-english string to this method, laravel translates it to English like in persian: زن…
Pooya Behravesh
  • 131
  • 2
  • 10
-1
votes
1 answer

Are there laravel method like in_array?

I try to use methods in https://laravel.com/docs/9.x/helpers instead of old php functions I used for many year. I did not find any laravel method like in_array. I tried to use Str::contains , but failed it. Seems different ? So any replacement of…
Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91
-1
votes
1 answer

How to use DB:: from helper class

I have a helper class name common.php in App\Helpers folder. I want to use DB:: facade here to use some db table. In helper method My code is - latest('id')->first(); …
mahbub
  • 103
  • 1
  • 3
  • 13
1
2