When using Maatwebsite\Excel in laravel project getting Could not open file "" for writing error

I want to generate an excel sheet with custom array in laraval. So I have used "Maatwebsite\Excel" package. Below is my export function, public function export(){ $users = [ [ ‘id’ => 1, ‘name’ => ‘Hardik’, ’email’ => ‘hardik@gmail.com’ ], [ ‘id’ => 2, ‘name’ => ‘Vimal’, ’email’ => ‘vimal@gmail.com’ ], [ ‘id’ => 3,… Read More When using Maatwebsite\Excel in laravel project getting Could not open file "" for writing error

How to count data from an array based on another array's value in PHP?

I have an array that contains data of incoming mail, looks something like this: $incomingMail = [ 0 => [ ‘title’ => ‘Title 1’, ‘areaCode’ => 101 ], 1 => [ ‘title’ => ‘Title 2’, ‘areaCode’ => 101 ], 2 => [ ‘title’ => ‘Title 3’, ‘areaCode’ => 102 ] ]; And another array containing… Read More How to count data from an array based on another array's value in PHP?

SQL Migration Error, SQLSTATE[42000]: Syntax error or access violation

Error: SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table subscriptions (id bigint unsigned not null auto_increment primary key, month int unsigned not null auto_increment primary key, price int unsigned not null auto_increment primary key, status… Read More SQL Migration Error, SQLSTATE[42000]: Syntax error or access violation

How to get list of ids from pagination query of the current page?

I have 1 pagination query for every: $pagination_query = Table1::…->paginate(100); then I have a second query that needs to use the list of ids from the pagination query: $second_query = Table2::whereIn(‘id’, $list_of_ids_from_pagination_query); How can I get the list of ids only from the paginated page so that I get 100 ids and not thousands of… Read More How to get list of ids from pagination query of the current page?

Como crear subconsulta SQL en Laravel

Hola tengo la siguiente consulta en SQL quisiera llevarla a Laravel pero no tengo ni la menor idea al respecto, mi consulta en SQL es la siguiente: SELECT SUBQUERY.*,SUM(SUBQUERY.TOTAL) AS IMPORTE,(SUBQUERY.amount+SUBQUERY.tip) AS IMPORT_PROPINA FROM ( SELECT notas.*, posee.qty, productos.shopping_price,(productos.shopping_price * posee.qty) AS TOTAL FROM posee JOIN productos ON productos.id = posee.id_producto JOIN notas ON notas.id… Read More Como crear subconsulta SQL en Laravel

Why value is deleted after alert pop up says that it can not be deleted?

Hello i have made a dynamic add and remove input fields and the code works great except the part when you reach the maximum limit to delete fields, this is my code: function rmv() { var count = document.getElementsByTagName(‘input’); if(count.length > 6){ $(document).on(‘click’, ‘#rmvbtn’, function () { $(this).closest(‘#dynamic’).remove(); }); }else{ alert(‘Order must have minimum one… Read More Why value is deleted after alert pop up says that it can not be deleted?

How to retrieve casted date without toArray or toJson?

For formatting some date column via casts, for example: protected $casts = [ ‘deadline’ => ‘date:d/m/Y’, ]; when getting column, it’ll return carbon instance: dd($model->deadline); // Illuminate\Support\Carbon @1671235200 {#1542 ▶} But even when it’s casted to string, it won’t be formatted as specified in cast: dd( (string) $model->deadline ); // "2022-12-17 00:00:00" Just when I… Read More How to retrieve casted date without toArray or toJson?

Why the delete query execute Laravel

Hello i am trying to make a simple delete function but its showing an error This is the code from the controller: public function destroy($id) { $clientOrder = clientHasOrder::where(‘order_id’,$id)->firstOrFail(); $clientOrder->delete(); return redirect(‘/’)->with(‘msg’,’Order Deleted successfully!’); } This is the model code: class clientHasOrder extends Model { use HasFactory; public $timestamps = false; protected $fillable = [… Read More Why the delete query execute Laravel

can't use assign role to User where i give factory

I want to create users with factories and directly assign roles to them. However, I encountered an error while seeding. My Error was like there : Method Illuminate\Database\Eloquent\Collection::assignRole does not exist. Here is the code from my databaseSeeder.php : $user = User::factory(10)->create()->assignRole(‘Admin’); That is my UserFactory code. This is default, I dont change anithing: namespace… Read More can't use assign role to User where i give factory