Category : laravel-8

I created an artisan command using this command: php artisan make:command –command=custom:command SomeCustomCommand After I ran the command it created the file below: <?php namespace AppConsoleCommands; use IlluminateConsoleCommand; class SomeCustomCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = ‘custom:command’; /** * The ..

Read more

I try to do decrypt value ? But it is giving this error. The payload is invalid. use IlluminateSupportFacadesCrypt; use IlluminateContractsEncryptionDecryptException; $identity_no = "eyJpdiI6Inhzakt4SE10Mk1TbGVNakZKb29nc2c9PSIsInZhbHVlIjoiaW9tWGVhOXZaQWlCYzhBbmNrbTV3dXdQYmNrTmt1S3dHKzdqelNLcFppbVJoR2s3NmptaVlKaU4rc1NSU3F2MW1oSVlJdU9OTEJuT05w ▶"; $decrypted_identityno = Crypt::decryptString($identity_no); dd($decrypted_identityno); die(); Sourc..

Read more

When I start seeding my database with db:seed, I got this error: Call to a member function count() on null at P:<folderName><folderName>srcvendorlaravelframeworksrcIlluminateDatabaseEloquentFactoriesHasFactory.php:18 14▕ { 15▕ $factory = static::newFactory() ?: Factory::factoryForModel(get_called_class()); 16▕ 17▕ return $factory ➜ 18▕ ->count(is_numeric($parameters[0] ?? null) ? $parameters[0] : null) 19▕ ->state(is_array($parameters[0] ?? null) ? $parameters[0] : ($parameters[1] ?? [])); 20▕ } ..

Read more

I want to add a session of warning like this at my Controller method: return view(‘panel.step3’ , compact(‘factor’ , ‘showStep’) )->with(‘warning’ , ‘test !’); And then on view panel.step3, I have added this: @dd(session(‘warning’)) But it says: NULL So what is going wrong here ? How can I properly add my session ? I would ..

Read more

I’m using Laravel Sanctum to allow users to generate personal access tokens (like GitHub). I’ve created a form where users can create a new personal access token submitting a name and some abilities. I would like to validate the name field to ensure that’s unique. public function rules(): array { return [ ‘name’ => [‘required’, ..

Read more

I want to show uploaded pictures of users at my Blade, so I added this: @foreach($users as $user) @if($user->photo_id) <td class="center"> <img src="{{ $user->photos->path }}" width="80"> </td> @else <td class="center"> </td> @endif @endforeach But it returns this error: Exception Property [path] does not exist on this collection instance. I have already added these relationships to ..

Read more

I am creating a controller that saves photos to the /storage/ folder. To protect myself from submitting a bunch of large photos and not to style their CSS, I wanted to resize them using the Intervention / image library. Unfortunately, despite following the installation instructions directly from the documentation, several uninstallations and reinstallations of the ..

Read more

I have PurchaseOrderProduct Model from which I am getting data like that PurchaseOrderProduct::with(‘products’)->with(‘warehouse_locations’)->with(‘productStatuses’)->with(‘purchase_orders’)->where(‘product_id’, $request->product_id)->where(‘free_qty’, ‘>=’, 1)->get(); Now in this table, I have the column expiry_date of type date i want to fetch data orderBy expiry_date nearest to the current date . Means purchase_order_product whose expiry date is nearest to current date should come first. Source: ..

Read more

I am trying to create a form submit but I bumped to a unexpected scenario. When form submitted by clicking the submit button The web app reroute to my index page of the resource route With the form variable and values appended in the URL. Example URL before submitting: http://127.0.0.1/admin/products/create URL after submitted: http://127.0.0.1/admin/products?_token=qQ4klvK2egdsP77iMY4RQhXd5laJDUONRyuh8oQd&productTitle=&productPrice= View ..

Read more

I have driver’s has many relation with run_sheets and runsheet can hasMany relation with consignments Driver model public function run_sheets() { return $this->hasMany(‘AppModelsAdminRunSheet’,’driver_id’); } runsheet model public function consignments() { return $this->hasMany(‘AppModelsAdminConsignment’, ‘runsheet_id’)->orderBy(‘delivery_address’); } so in order to take count of conisgnments i have to use loops which increase the number of queries and page ..

Read more

I am adding a textarea to my blade template and populating it with a read-only list of items server-side. This is what I got: <div class="form-group"> <textarea class="form-control" rows="10" readonly> @foreach($items as $item) {{trim($item)}} @endforeach </textarea> </div> My problem is it is not displaying correctly, I get lots of whitespace before each line. so it ..

Read more