Skip to content
Fix Code Error

Tag: laravel

What should I use to get an attribute out of my foreign table in Laravel?

July 18, 2021 by Code Error

Posted By: Anonymous I am trying to access the price of a product. I am using a orderItem table which has a foreign ID that goes to the product table. I then want to access the price of a corresponding product. When I do so it comes up with this error: Property [price] does not …

Continue Reading

Does defaults() method exist in Password?

July 17, 2021 by Code Error

Posted By: Anonymous i made a service provider to validate the password in Laravel 8, but i get this error: Call to undefined method IlluminateValidationRulesPassword::defaults() PasswordRuleServiceProvider was added in app.php // Custom Service Providers AppProvidersPasswordRuleServiceProvider::class, This is the provider: <?php namespace AppProviders; use IlluminateSupportServiceProvider; use IlluminateValidationRulesPassword; class PasswordRuleServiceProvider extends ServiceProvider { public function register() { …

Continue Reading

how to make Select function used in model dynamically select the column to export in excel in Laravel using Maatwebsite

July 17, 2021 by Code Error

Posted By: Anonymous I am working in the project using Laravel 8 and waatwebsite(to work with excel). I have one Table name Docs in my database which have 20 columns value. I dont Know how to make the select() function dynamical so that i can pass the column name from controller to extract the query …

Continue Reading

Laravel 7 migrate error Table ‘skz.master_courses’ doesn’t exist SQL: select * from

July 17, 2021 by Code Error

Posted By: Anonymous I have a project on which I need to run php artisan migrate. It should be ease but I am getting an error php artisan migrate IlluminateDatabaseQueryException SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘skz.master_courses’ doesn’t exist (SQL: select * from master_courses where date_from > 2021-06-01 and master_courses.deleted_at is null …

Continue Reading

Ajax call having Inner Join query in Eloquent Laravel 8 not working

July 17, 2021 by Code Error

Posted By: Anonymous I wanted to fetch data from two tables using inner join in Laravel 8 and show it in front end as datatable by Ajax. But ajax call is returning internal server error. Here is my controller if(request()->ajax()) { return datatables()->of(Machine::select("machine_base.id as id", "machine_base.machine_name as machine_name", "machine_base.machine_category as category_id", "item_category_base.category as category_name")) ->innerJoin("item_category_base", …

Continue Reading

How to echo function name on Laravel blade

July 17, 2021 by Code Error

Posted By: Anonymous my function is public function testfunction(){ return view(‘back.page.simple’); } my blade template is "simple" i will try dispaly function name in my simple blade file. how to get function name? Solution public function testfunction(){ $functionName = "testfunction"; return view(‘back.page.simple’, compact(‘functionName’)); } And in blade you will access name like this: <p>{{ isset($functionName) …

Continue Reading

Laravel 7 amd Babel

July 17, 2021 by Code Error

Posted By: Anonymous I am using laravel 7. How can I use Babel with mix.combine ? I can find something in the docs but only mentions vue and react automatically using Babel? I am used tot Gulp and not Webpack. With Gulp I just use it for converting es6 to es5. Solution Laravel mix is …

Continue Reading

How to get Rows that falls in between dates and get their child Rows in another table – Laravel Eloquent

July 17, 2021 by Code Error

Posted By: Anonymous I want to create a single query that will fetch all Events that fall between dates. I also want to get all their child Event Images. Can I get all of this into a single query? Event Model public function eventImages() { return $this->hasMany(EventImage::class, ‘event_id’); } Event Images Model public function event() …

Continue Reading

Laravel, how to display Values in DB with just given IDs?

July 17, 2021 by Code Error

Posted By: Anonymous im trying to get 5 data from DB with their ID ? HTML <input type="number" name="cid1"> <input type="number" name="cid2"> <input type="number" name="cid3"> <input type="number" name="cid4"> <input type="number" name="cid5"> Route Route::post(‘/selectCampaign’,’[email protected]’)->name(‘selectCampaign’); Controller – im Trying to get Just 1 ID and its not Working public function selectCampaign(Request $request) { $id1 = request(‘cid1’); $offers …

Continue Reading

How to fix Vue packages version mismatch from vue-loader?

July 17, 2021 by Code Error

Posted By: Anonymous I am trying to install the Vue Filemanager to my package.json. However, when I try to install the package using npm install and npm run dev I get this error: ERROR in ./resources/assets/js/file-manager/FileManager.vue Module Error (from ./node_modules/vue-loader/lib/index.js): Vue packages version mismatch: – [email protected] (/var/www/node_modules/vue/dist/vue.runtime.common.js) – [email protected] (/var/www/node_modules/vue-template-compiler/package.json) This may cause things to …

Continue Reading

getting records by id and querying there relation with ‘wherebetween’ using Laravel and eloquent

July 17, 2021 by Code Error

Posted By: Anonymous i’m trying to get all measurements from a certain recorder between a certain timespan. If i remove the "->wherebetween()" part of the query and view the results then I get all the sensors of that recorder and all related measurements of that sensor. But I’m not able to execute a wherebetween on …

Continue Reading

syntax error, unexpected token “

July 16, 2021 by Code Error

Posted By: Anonymous There are an error showing when i add @if ({{Auth::user()->utype}} == "ADM") Line of code in product.blade.php. </head> @if ({{Auth::user()->utype}} == "ADM") <body> </body> @endif This is my controller named ProductController. public function index() { $products = Product::all(); return view(‘product’, compact(‘products’)); } public function create() { return view(‘product’); } public function store(Request …

Continue Reading

Remove duplication of code in Laravel- optimize

July 16, 2021 by Code Error

Posted By: Anonymous I want to how to optimize my code below without affecting its output in laravel? $user = User::with(‘voucherUtilizations.voucher’) ->with(‘voucherUtilizations’, function ($query) use($campaignId ,$date_from,$date_to) { if ($campaignId && $date_from &&$date_to) { return $query->where(‘campaign_id’, $campaignId) ->whereDate(‘created_at’, ‘>=’, $date_from) ->whereDate(‘created_at’, ‘<=’, $date_to) ->whereNotNull(‘voucher_id’); } if ($campaignId) { return $query->where(‘campaign_id’, $campaignId) ->whereNotNull(‘voucher_id’,); } if ($date_from &&$date_to) …

Continue Reading

Laravel – How to validate based on condition using Rules Request

July 16, 2021 by Code Error

Posted By: Anonymous In my Laravel-8 application, by default company_id in the table is 0: I have this Request Rules validation: ’email’ => [ ‘required’, ’email’, ‘min:5’, ‘max:80’, Rule::unique(‘users’, ’email’) ], ‘company_id’ => [ ‘nullable’, ], I want email to be unique based on two conditions: If no company_id is selected, the email should be …

Continue Reading

PHP S3 – How to get all versions of a specific file

July 16, 2021 by Code Error

Posted By: Anonymous I have a Laravel project and a version enabled S3 bucket. I can list the versions of all objects within the bucket using the listObjectVersions method. My attempt to list the versions of a specific object is as follows: $result = $client->listObjectVersions([ ‘Bucket’ => Config::get(‘filesystems.disks.s3.bucket’), ‘Key’ => $folder . ‘/’ . ‘test.png’, …

Continue Reading

switch custom using laravel , ajax

July 16, 2021 by Code Error

Posted By: Anonymous I have the following datatable : In My controller I have this function which gets data : function getdata(Request $request) { if(request()->ajax()) { return datatables()->of(Casting::latest()->get()) ->addColumn(‘action’, function($data){ $button = ‘<table><tr><td>’; $button .= ‘<button type="button" name="edit" id="’.$data->id.’" class="edit btn btn-primary btn-sm">Modifier</button>’; $button .= ‘</td><td>’; $button .= ‘<div class="custom-switch custom-switch-secondary-inverse mb-2 custom-switch-small"> <input class="custom-switch-input" …

Continue Reading

Laravel – Missing required parameters for [Route: reset-password.index]

July 16, 2021 by Code Error

Posted By: Anonymous i’m just a newbie in Laravel, so still not that good to work on such ready projects, anyway when ever users try to reset password it fails showing that: ~/public_html$ php artisan queue:work [2021-05-29 19:52:02][182577] Processing: AppMailCoreResetPassword [2021-05-29 19:52:02][182577] Failed: AppMailCoreResetPassword and when i checked the log files, i found this error: …

Continue Reading

laravel raw query date comparisons

July 16, 2021 by Code Error

Posted By: Anonymous I have a string columns ddate = (‘2020-06-02’) and time_start = (‘4:25 PM’) which I want to compare to date(‘Y-m-d H:i A’). Say that date(‘Y-m-d H:i A’) = 2021-06-02 01:14 AM… What I want is to show all rows where ddate+time_start > date(‘Y-m-d H:I A’) my where clause is: ->whereRaw(‘CONCAT(event_date, " ", …

Continue Reading

I am getting this error with laravel scout: Your requirements could not be resolved to an installable set of packages

July 16, 2021 by Code Error

Posted By: Anonymous I’m getting this error while installing Laravel Scout: Problem 1 – laravel/scout[v9.1.0, …, 9.x-dev] require illuminate/bus ^8.0 -> found illuminate/bus[v8.0.0, …, 8.x-dev] but these were not loaded, likely because it conflicts with another require. – Root composer.json requires laravel/scout ^9.1 -> satisfiable by laravel/scout[v9.1.0, 9.x-dev]. Use the option –with-all-dependencies (-W) to allow …

Continue Reading

Laravel 8: Is there a way access bound instance via and identifier? And what’s the correct way for object caching?

July 16, 2021 by Code Error

Posted By: Anonymous I am new to Laravel. My goal is to essentially cache some service class instances into Laravel container and retrieve them when needed. In particular, I want to cache two instances of the same class twice and identify them using string identifiers. When I bind an instance to the container using app()->bind …

Continue Reading

I want to get the next id that will be created but not yet in laravel

July 16, 2021 by Code Error

Posted By: Anonymous I want to get the next id that will be created but not yet in laravel. Is this code correct? $tableStatus = DB::select("show table status from database_name where Name = ‘table_name’"); if (empty($tableStatus)) { throw new Exception("Table not found"); } // Get first table result, get its next auto incrementing value echo …

Continue Reading

Mysql order by field with given values which has NULL in between

July 16, 2021 by Code Error

Posted By: Anonymous I’m trying to sort a query by given values like this: ORDER BY FIELD(items.stock_id, 1, 5, NULL, 3, 6) But it seems it doesn’t work and null comes first or last depending on it being descending or not. The order is not always the same hence [1,5,NULL,3,6] changes every time and is …

Continue Reading

Laravel belongsto relations get error SQLSTATE[42S22]

July 15, 2021 by Code Error

Posted By: Anonymous I get an error when calling $ event-> courts "message": "SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘courts.events_id’ in ‘where clause’ (SQL: select * from courts where courts.events_id = 1 and courts.events_id is not null)", Events <?php namespace AppModels; use IlluminateDatabaseEloquentFactoriesHasFactory; use IlluminateDatabaseEloquentModel; class Events extends Model { use HasFactory; /** * …

Continue Reading

ErrorException: Undefined index: id

July 15, 2021 by Code Error

Posted By: Anonymous I’m trying to fetch data from this JSON URL https://api.github.com/users/Kirolos-victor/events/public but I don’t understand why am I getting this error I hope someone can help me, Thanks. public function score(Request $request) { $validator=Validator()->make($request->all(),[ ‘name’=>’required’, ]); if($validator->fails()) { return response()->json([‘message’=>’failed’,’data’=>$validator->errors()],400); } $json=Http::get("https://api.github.com/users/$request->name/events/public")->json(); $id=collect($json["id"]); return $id; } Solution looks like that end point is …

Continue Reading

cannot add or update a child row a foreign key constraint fails laravel factory

July 15, 2021 by Code Error

Posted By: Anonymous I have users table with 20 rows. When I factored user_transaction table, I see this error. IlluminateDatabaseQueryException with message ‘SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fa ils (webafra_testa.user_transaction, CONSTRAINT user_transaction_userid_foreign FOREIGN KEY (userId) REFERENCES users (id) ON DELETE CASCADE) (SQL: inse rt …

Continue Reading

Route undefined when importing in Laravel excel

July 15, 2021 by Code Error

Posted By: Anonymous I’m trying to use the import funtionality of Laravel excel, but it always return the Route: undefined error even if the route is registered. Please see my code, and details below. web.php Route::get(‘admin/doctors/bulk-upload/data’, [ ‘middleware’ => [‘auth’, ‘auth.admin’], ‘as’ => ‘admin.doctors.bulk-upload.data’, ‘uses’ => ‘[email protected]’ ]); Route::post(‘admin/doctors/bulk-data/upload’, [ ‘as’ => ‘admin.doctors.bulk-data.upload’, ‘uses’ => …

Continue Reading

Redirect to a path relative to root path using javascript

July 15, 2021 by Code Error

Posted By: Anonymous I’m working on a project where I have a form to add a thread as following : The share button validate and save the thread to the database : $(‘.share-thread’).click(function() { // Validations let data = { ‘_token’:csrf, ‘subject’: $(‘#subject’).val(), ‘category_id’: $(‘#category’).val(), ‘content’:simplemde.value(), ‘thread_type’: $(‘#thread_type’).val() }; $.ajax({ type: ‘post’, data: data, url: …

Continue Reading

How can i get only some fields from many to many relationship?

July 15, 2021 by Code Error

Posted By: Anonymous I would like to get some fields from a relationship that i have defined. If i find all the ingredients of a menu like this: $ingredients = auth()->user()->menu->ingredients(); I want to send to the view only the id and name fields of each ingredient, something like this: $ingredients = auth()->user()->menu->ingredients()->withColumns(‘id’, ‘name’); How …

Continue Reading

Undefined Index in Maatwebsite Excel

July 15, 2021 by Code Error

Posted By: Anonymous I am trying to Import Excel Data in Laravel and Insert into Database. I am using maatwebsite/excel version 3 composer package. Error: Undefined index: customer_name Blade file: import_excel.blade.php <form method="post" enctype="multipart/form-data" action="{{ url(‘/import_excel/import’) }}"> {{ csrf_field() }} <div class="form-group"> <table class="table"> <tr> <td width="40%" align="right"><label>Select File for Upload</label></td> <td width="30"> <input type="file" …

Continue Reading

how to get only withCount attribute

July 15, 2021 by Code Error

Posted By: Anonymous I have a situation where I only need to return the withCount attribute for example, I have $data = SystemReport::withCount([‘unit’ => function($query) { $query->where(‘totalPercentage’, ‘=’, 100); }])->get() ->groupBy(function($val) { return Carbon::parse($val->updated_at)->format(‘M’); }); that returns { "id": 1, "unit_id": 1, "human_resource_id": null, "quality_id": null, "construction_id": 1, "digital_transformation_id": 1, "confirmationDate": "2024-11-10", "expectedDate": "2024-11-20", "totalPercentage": …

Continue Reading

Posts navigation

  • 1
  • 2
  • 3
  • 4
  • …
  • 34
  • Next

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error