Is possible to modify the default value response from Laravel Eloquent? I have an API and my database has a migration payment. My payment has a column integer status. $table->integer(‘status’)-&…
Tag: laravel
How to read json file from url in php/laravel?
I want to open a JSON from url in php/laravel file. this is my code : {{ini_set(“allow_url_fopen”, 1)}} {{$id_ = $blog_post->featured_media}} {{$url_ = ‘http://example.net/blog/wp-json/wp/v2/media/…
Illegal operator and value combination when paginating in Laravel
I am a newbie at Laravel 6. In the view, I created a form, and when it’s submitted, it should return a table filtered with the links of pagination at the bottom. All works correctly, but when I click …
DateTime::__construct(): Failed to parse time string in Laravel
Upon adding the following where condition : ->whereBetween(‘p.created_at’, [ Carbon::parse(‘c.created_at’)->format(‘Y-m-d 00:00:00’), Carbon::now()->endOfDay()…
Laravel class not being found in a model
I am trying to get my project to use authorization roles to restrict users to certain featuers and I am following along with a tutorial. When I make a call to a class in my user.php file I am getting an error that the class AppRole can’t be found. I am not sure if it is a namespace issue but
how can i to convert an database object to integer in PHP (laravel)
i have a select that returns a integer value but in the variable it is stored a object that is obvious i neeed to convert to integer $n = DB::select(‘select top 1 id form tags order by id DESC’); …
How to prevent Laravel event() from firing during unit tests
I have a class that uses Laravel’s global event() function to fire off a single event when a model is changed. The only way I have been able to prevent this event from firing during unit tests is to actually namespace and declare a new event() function in the test itself and make it do nothing. It works…
Unknown column “has” in ‘where clause
I am using laravel 5.7 When I use whereHas to check a relation’s existence, I face with Unknown column “has” in ‘where clause Error! Why? this is my code: $query->whereHas(‘departures’, function …
PHP, Laravel – Concatenation with String to Model
Is is possible to concatenate a string to Model? The below doesn’t seem to work. I have Car Model and Train Model. Vehicle will be either Car or Train. $vehicle = ‘Car’; $result = $vehicle::where(‘…
How to add a where condition to my search?
I need to add a where condition to my search function, but I don’t know how to add this to my final results. Now, for an example: now, my search is searching for the name in table career_solutions, …