I am new to laravel. This is my view (bids.new): <form method="post" action="{{ route(‘bids.storeBid’, $project->id) }}" enctype="multipart/form-data" > @csrf *content* <div class="row pt-4"> <button class="btn btn-primary">Place Bid</button> </div> </form> This is my route: Route::get(‘/bids/new/{id}’, ‘[email protected]’)->name(‘bids.new’); Route::post(‘/bids/{id}’, ‘[email protected]’)->name(‘bids.storeBid’); BidController: public function storeBid(Request $request, $id) { *content* } When i clicked on Place Bid button in my ..

Read more

Currently I have users/permissions/roles a user can have direct permissions or permissions through roles. Now i want to scope users by any of their permissions, Currently I have this. $query->whereHas(‘permissions’, function(Builder $subQuery) use ($permissions){ //doing a long query }); $query->orWhereHas(‘roles.permissions’, function(Builder $subQuery) use ($permissions){ //same long query }); How can i reach it so i ..

Read more

Greetings to all smart developers. I am just starting to write in laravel and want to ask you a question. While working with a project and performing an intermediate task of implementing a basket of products, I ran into the following problem: I needed to update my project, and there was a bug in it ..

Read more

I have 3 tables – users, graduation_institutes, graduation_degrees I defined a pivot table – graduation_degree_user graduation_degree_user table has data like below – id——–doctor_id——–graduation_degree_id———-graduation_institute_id———year In my User model, I defined relation like below – public function graduations(){ return $this->belongsToMany(‘AppModelsUserGraduationDegree’)->withTimestamps(); } In my controller, I m doing – if($request->has(‘graduations’)){ $user->graduations()->sync($request->graduations); } return $user->graduations; Where graduations is an ..

Read more

$assets = Asset::where(‘group_id’, $request->group_id)->select(‘name’)->get()->toArray(); dd($assets); output: array:2 [▼ 0 => array:1 [▼ "name" => "wordpress" ] 1 => array:1 [▼ "name" => "joomla" ] ] Error: Array to string conversion $assets = Asset::where(‘group_id’, $request->group_id)->select(‘name’)->get()->toArray(); dd(implode(‘,’, $assets)); ……………………………………………………………………………………………………………………………. Sourc..

Read more

I have a problem. I try genrate .docx file to .pdf file with Laravel library "mPDF" and got this error: My code on controller: $domPdfPath = base_path(‘vendor/mpdf/mpdf’); PhpOfficePhpWordSettings::setPdfRendererPath($domPdfPath); PhpOfficePhpWordSettings::setPdfRendererName(‘mPDF’); //Load word file $Content = PhpOfficePhpWordIOFactory::load(public_path( ‘/uploads/word/no12.docx’)); //Save it into PDF $PDFWriter = PhpOfficePhpWordIOFactory::createWriter($Content,’PDF’); $PDFWriter->save(public_path( ‘/uploads/word/result3.pdf’)); dd($PDFWriter); And error: PDF rendering library or library path has ..

Read more

I have a table called ads, which is like this:- |—————————————————| | id | name | ad_number | category_id | |—————————————————| | 1 | Test 1 | AD1230045 | 1 | |—————————————————| | 2 | Ad Test2 | AD2381923 | 1 | |—————————————————| And I have another table called chats which is like this:- |—————————————————————–| ..

Read more

I have a table named company_profile I want to search name ignoring case and space. Let me explain here id #1 has value of name: Bracnet Academy when I try to add another entry with bracnetacademy then it will update id #1 instead of inserting new one. I tried as follows: function onSetupCorporateName(){ $data = ..

Read more

I know this question may sound stupid, but I’m working with Laravel, and I want to return an alert message for one of my route which is placed inside of a group route: Route::middleware(‘auth’)->group(function(){ Route::get(‘profile’, [AppHttpControllersProfileController::class, ‘index’])->name(‘profile’){ alert()->success(‘welcome’,’message’)->persistent(‘Ok’); } Route::get(‘profile/twofactor’, [AppHttpControllersProfileController::class, ‘manageTwoFactor’])->name(‘profile.2fa.manage’); Route::post(‘profile/twofactor’, [AppHttpControllersProfileController::class, ‘postManageTwoFactor’]); }); As you can see for the route profile I ..

Read more

how to display the following rows and columns in a foreach? here’s my code public function index() { $users = User::with(‘absen’)->get(); $period = CarbonPeriod::create(‘2020-11-25′,’2020-11-30’); return view(‘absen.index’,compact(‘users’,’period’)); } –controller– <div class="box-body"> <table class="table table-bordered"> <thead> <tr> <th>tanggal</th> <th>nama</th> <th>masuk</th> <th>keluar</th> </tr> </thead> <tbody> @foreach($period as $date) @foreach ($users as $user) <tr> <td>{{$date->format(‘Y-m-d’)}}</td> <td>{{ $user->nama}}</td> @foreach ($user->absen ..

Read more

I’m trying to dump a .php file created from a blade template into the public folder, this way: $html = view(‘input_file’, [ ‘variable’ => ‘text’ ]); File::put(public_path(‘output_file.php’), $html); where my input_file.blade.php is: <!DOCTYPE html> <html> <body> <div>{{ $variable }}</div> <div><?php echo mt_rand(); ?></div> </body> </html> What I want to achieve is to have output_file.php like ..

Read more

How to sort collections by specific value and id. I need to sort records where the name = X should be the first in the order. product model |———————|——————| | id | Name | |———————|——————| | 1 | a | |———————|——————| | 2 | x | |———————|——————| | 3 | b | |———————|——————| | 4 ..

Read more

so i just installed ffmpeg package in my laravel 8 project using composer require pbmedia/laravel-ffmpeg i also publish the file when added class in app.php file as documentation says, but i don’t know how can i use this i want to use this here use FFMpeg; public function videoUpload(Request $request){ $files=$request->file(‘files’); $imageArray=FFMpeg::open($files) ->export() ->resize(640, 480); ..

Read more