Category "laravel"

Laravel Observer not triggered on UpdateorCreate

I have Model Model1 where I want to update a particular column rank on saved. protected static function boot() { parent::boot(); static::saved(function

Laravel 5.4: How do I get records from just this week?

To get all records of the current day, I did $dt = Carbon::now(); $dataToday = Data::whereDay('created_at', $dt->day)->get(); To get records from this

Access denied for user 'homestead'@'localhost' (using password: YES)

I'm on a Mac OS Yosemite using Laravel 5.0. While in my local environment, I run php artisan migrate I keep getting : Access denied for user 'homestead'@'local

How to Install Composer Require doctrine/dbal

In the Laravel framework, I am trying to modify my columns using change() by migrations. Right now, I need to install... composer require doctrine/dbal I am

Issue with POST requests with Laravel Sanctum and Postman

I have a problem with Sanctum and Postman that's related to this post: SPA Authentication Issues with Sanctum and Postman I followed everything from the Laravel

Laravel 5 issue with wherePivot

I am working with Laravel 5 and I am having issue getting ->wherePivot() to work on a Many-to-Many relationship. When I dd() the SQL it looks like Eloquent i

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

By using Maatwebsite/Laravel-Excel version 3.1 to import excel sheet, here I faced an issue date time column of the excel sheet returns unknown number. How to s

How can I resolve "Your requirements could not be resolved to an installable set of packages" error?

When I run composer update I receive some wired output. Here is my composer.json look like. { "name": "laravel/laravel", "description": "The Laravel

Laravel implode array items to new lines

Here is my array from hasMany relationship in Laravel framework. $array = ['php','css','hrml']; How can I display as below using implode function. (code in m

How to Make Laravel Eloquent "IN" Query?

I want to make query in Laravel Eloquent like here its raw MySQL query SELECT * from exampleTbl where id in(1,2,3,4) I have tried this in Laravel Eloquent

how to rename foreign key in Laravel

I want to rename the foreign key in Laravel. This is how, I have created it: Schema::create('holidays', function (Blueprint $table) { $table->increments(

Php artisan migrate no such file or directory

I created a make:migration when I try to run the migration I get the following error No such file or directory (SQL: select * from information_schema.tabl

Laravel lang slug in url

I've followed this article to add multi language into my app and it's working fine, the only issue i need to solve is that languages slug won't add to the url.

Laravel Displaying image from database

so i wanted to display the image not the image name in my views. i got this in my views <img src="{{$post->image}}" /> what i want is to display t

Is it necessary to avoid loops for updating models in laravel?

I'm trying to sort multiple records for a model based on a field and store their ranks in DB. Like below: $instances = Model::orderBy('field')->get(); $ran

How do I call Validator from a namespace with an already existing Validator class

I'm trying to test a function in phpspec which calls Laravel's Validator::make function (http://laravel.com/docs/4.2/validation) However, I'm trying to call th

(Laravel) How to delete multiple models including optional relationships?

Summary I'm trying to let my model controller delete multiple models (selected by an array of IDs) including their selected related models (selected by an arra

Eloquent insert id with sequence next value

I would like to create a new record in a PostgreSQL database table with Laravel eloquent but the table id is not auto incremented and it's make my life more dif

Laravel how to get query with bindings?

I have some query that I need to pass to another query using query builder $query = DB::table('table')->whereIn('some_field', [1,2,30])->toSql(); Model::

Respond with status code 401 on authentication failure using Laravel and Passport?

I'm configuring a Laravel project to use Passport token authentication. Everything seems to be working, but when the auth:api middleware fails, it responds to t