المشاركات

عرض المشاركات من نوفمبر, 2022

How to send SMS using firebase in laravel

I am developing a laravel application,in which while user register, i want to send the registration code through SMS, i don't want to use any paid services.I heard about firebase free SMS gateway. Is there any option to send SMS through firebase from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32S92Gv via IFTTT

Why Laravel Sanctum SPA Authentication always keep the user logged in?

I used Laravel Sanctum SPA authentication. I can log out the user but I am wondering why is it that the user is still logged in even when I close the browser. I don't even implement the remember me function. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3faF5q7 via IFTTT

Relation query undefined method

In my setting model class i have this public function user() { return $this->hasMany('App\User'); } and in my user model class i have this public function settings() { return $this->belongsTo('App\settings', 'id'); } I tried both these queries, trying to get the user information but failed. $data = DB::table('settings') ->where('id', '=', $id) ->get() ->toArray(); and $table = \App\settings::where('id', '=', $id); $query = $table->user() ->get() ->toArray(); I'm getting this error Call to undefined method Illuminate\Database\Eloquent\Builder::user() How do you do relation query? Sorry new to laravel here. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/35H8wNH via IFTTT

Store data into database using request json string in laravel

I am having a table name Student ( id , name , division ). To store data into this table I am sending json string as a request to the api in laravel. Request json string is, { "name":"abc", "division":"a", "city":"xyz" } Controller Code public function registerStudent(Request $request){ $requestData = $request->json()->all(); $studentModel = Student::create($requestData); } Student Model class Student extends Model { protected $fillable = [ 'id', 'name','division' ]; } When i execute this code , i get the following error, Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'city' in 'field list' (SQL: insert into `Student`... now my question here is, in what way I can store the data into database from json request with having extra keys into json object/array. from Newest questions tagged laravel-5 - Stack Overflow...

Laravel route not found when route exists

When I try to access my laravel site I get this error in the console. Laravel development server started: <http://127.0.0.1:8000> [Mon Nov 16 10:39:15 2022] PHP Fatal error: Uncaught InvalidArgumentException: Route [home] not defined. in /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:389 Stack trace: #0 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(822): Illuminate\Routing\UrlGenerator->route('home', Array, true) #1 /Users/threeaccents/code/src/gitlab.com/few/bodylove/storage/framework/views/e071ac62e490c49233841ae8b6b3906075bc0187.php(6): route('home') #2 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(43): include('/Users/threeacc...') #3 /Users/threeaccents/code/src/gitlab.com/few/bodylove/vendor/laravel/framework/src/Illuminate/View/Engine...

laravel validation, how to add validation rule on client side?

//html code <form> <input type="radio" id="defult" name="price_type" value="default"> <label for="defult">Default Price</label><br> <input type="radio" id="custom" name="price_type" value="custom"> <label for="custom">Custom Price</label><be> <input placeholder="Custom Price" class="form-control" name="custom_price"> </form> $('input[type=radio][name=price_type]').change(function() { if (this.value == 'default') { //make custom_price optional } else if (this.value == 'custom') { //make custom_price required } }); Actually, I have a radio box for the custom price or default price, if the user selects the custom price then want to make input[name=custom_price] required or if the user selects default price then make input[name=custom_price]...

my project laravel when i click submit in form with errors in input my view refresh multiple time so i can't see message errors

this my view code here i try to do form with validate and div with type of errors: @if(count($errors) > 0) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li></li> @endforeach </ul> </div> @endif <form action="add" method="POST"> <!--Securite--> Product name <input type="text" value="" class="form-control " name="name" placeholder="enter product"> <br> Product Price <input type="text" class="form-control " value="" name="price" placeholder="enter price"> <br> <input type="submit" value="Add Product"> </form> @endsection from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32QQuGF via IFTTT

Laravel \Illuminate\Filesystem\Filesystem File:files() count only the files that have specific extension e.g jpg png in all subfolders

i can count files in the folder with this : \Illuminate\Filesystem\Filesystem\File::files($path) then i can count all files in all subfolders (with specific storage) foreach ($directories as $directory) { $path = Storage::disk($this->disk)->path($directory); $files = \Illuminate\Filesystem\Filesystem\File::files($path); if ($files) { $count += count($files); } } } i can count all files in this folder How can i count only png or jpeg files with minimum overload? thanks in advanced! from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3pyGOKN via IFTTT

get page number in object of laravel

i have object given below and i wanted to pagination in this how can i get $productListArray = array(); $productListObject = ((object)[ "id"=>$productList->id, "title"=>$productList->title, "slug"=>$productList->slug, 'categoryName'=>$categoryName[0]->cat_title, 'brand'=>$brandName[0]->brandname, 'minMrp'=>$minMrp, 'maxMrp' =>$maxMrp, 'minSellingPrice' => $minSellingPrice, 'maxSellingPrice' => $maxSellingPrice, 'rating'=>$productList->rating, 'rating_count' => $productList->rating_count, 'image' => $img[0] ])->paginate(); array_push($productListArray, $productListObject); } return response()->json($productLi...

Search in the related model in Laravel

I have post table like this : id | post_title | category_id and this is category table id | category_title this is the relation between these two which is inside post model : public function category() { return $this->belongsTo(Category::class, 'category_id', 'id'); } I want to get the record of post table where category_title or post_title matches the keyword entered by user. I'm retrieving data something like: Post::where(['title'=>$request->title])->with('category')->paginate(10); but here it is only fetching Post title but i also want it to search it in category title. Any help is highly appreciated. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2UtCgaj via IFTTT

Larave 5.4 Bootstrap cache force delete

Hello I have some question. In my case AM 1:00 some-laravel-project/bootstrap/cache/services.php was force deleted but i don't know reason... our code don't have any call artisan clear cache command and anyone don't call manually artisan command anybody has same case like my case? if you have same case like my case and find cause plz comment to my question cause our enviroment AWS EC2 laravel version : laravel 5.4.33 php version : PHP 7.1.4 (cli) (built: Oct 26 2017 15:49:30) ( ZTS ) Apache version: Apache/2.2.15 (Unix) OS : CentOS release 6.9 (Final) dependency { "php": ">=5.6.4", "ammadeuss/laravel-html-dom-parser": "^1.0", "aws/aws-sdk-php": "^3.160", "barryvdh/laravel-debugbar": "^2.3", "caouecs/laravel-lang": "~3.0", "doctrine/dbal": "^2.5", "fightbulc/moment": "^1.26", "graham-campbell/excep...

How to add watermark to image on upload in laravel 5.8

I want to add watermark when a user uploads an image on the system. My current code works fine but I need it to work on upload. What do I add to my code? My WatermarkController file <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Image; class WaterMarkController extends Controller { public function imageWatermark() { $img = Image::make(public_path('images/background.png')); /* insert watermark at bottom-right corner with 10px offset */ $img->insert(public_path('images/watermark.png'), 'bottom-right', 10, 10); $img->save(public_path('images/background.png')); $img->encode('png'); $type = 'png'; $new_image = 'data:image/' . $type . ';base64,' . base64_encode($img); return view('show_watermark', compact('new_image')); } public function textWatermark() { $img = Image::make(public_path('images/background.jpg')); $img->text('MyNotePaper', 710,...

laravel artisan error while clearing config cache

when I run php artisan cache:config the command throw the following error PHP Warning: require(): Filename cannot be empty in /home/****/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php on line 71 PHP Fatal error: require(): Failed opening required '' (include_path='.:/usr/share/php') in /home/****/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php on line 71 I have no idea what causing this and how to fix it. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Uz7mwY via IFTTT

how to take data in chunk and pass it view in laravel

I am using query which is taking data from database but it is taking too long becuase i am using doesthave() method with this query which is checking whole table . Here is the query $consignments = Consignment::where('customer_id', $invoice->customer_id)->doesnthave('invoice_charges')->get(); So now I am thinking I should take records from database in chunk . How I can do it What I want is in the End $consignments variable should have all the consignments data as it is taking from database directly from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32Na86u via IFTTT

Why doesn't it correctly filter items in a hasOne Laravel relation using spaces blanks

I have a relationship defined in laravel - Warehouse - Product, when I search for text strings to compare with the product description, and I add spaces it does not filter correctly. This I tried and Other question . but it doesn't filter me correctly Warehouse::whereHas('item', function($query) use($search,$column) { //$query->whereRaw(DB::raw("LOWER(REPLACE(description, ' ', '')) LIKE CONCAT('%',LOWER(REPLACE('".$search."', ' ', '')), '%')" )); // $search = 'la es'; $query->where( $column, 'LIKE','%'.str_replace(' ', '', $search).'%'); }) ->orderBy('item_id') ->get() from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3kCYeSG via IFTTT

Laravel Multi language site database

Laravel e-commerce site. Arabic and English languages website. I have tried to develop Multilanguage site with laraval. But I am confused at the below point. Suppose I have Category table with title field. I want to insert title field in the two language. So i have created migration for title_en and title_ar . <?php namespace App; use App\Traits\MultiLanguage; use Illuminate\Database\Eloquent\Model; class Category extends Model { use MultiLanguage; protected $fillable = [ 'title_en', 'title_ar', ]; /** * This array will have the attributes which you want it to support multi languages */ protected $multi_lang = [ 'title', ]; } Here is multi language traits: <?php namespace App\Traits; use Illuminate\Support\Facades\App; trait MultiLanguage { public function __get($key) { if (isset($this->multi_lang) && in_array($key, $this->multi_lang)) { $key = $key . '_' ....

Allowing students (kids) use parent email to login in laravel project [closed]

A Parent wants to apply for his/her children, who are a minimum of 2 years old, in an educational institution. The students(kids) don't have email and thus parent's email is used for the students. Question: how to login the children using the parent's email using the same login form? Note: Currently, I have separate login and registration forms for each ( student and guardian) which I am merging. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32MrDUn via IFTTT

How to specify columns we want from commentator with beyondcode/laravel-comments

I am using beyondcode/laravel-comments ( https://github.com/beyondcode/laravel-comments ) and I try to specify columns I want to get from commentator. here is the code: $comment = $post->comments()->with('commentator', function ($query) { $query->select('commentator.name', 'commentator.email'); //or $query->select('users.name', 'users.email'); })->latest(); I am getting error that said Undefined table: 7 ERROR: missing FROM-clause entry for table "commentator" // or users How can I fix it? thanks from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/35q8M3l via IFTTT

Laravel, only first element of array passed to route is readable

From a blade template I want to pass an array with a variable amount of values to a route, as described in the answer here . However when I do this I can only ever access the first value in the array I pass to the route. This is how I call the route in the blade template: this is my route from web.php : Route::get('stats/downloads', 'StatsController@view_stats_downloads')->name('stats.downloads'); and my controller: public function view_stats_downloads(Request $request){ // get the input parameters $group_by = $request->get('group_by'); $stat_kind = $request->get('stat_kind'); $company = $request->get('group_by'); $user = $request->get('user'); $start = $request->get('start'); $end = $request->get('end'); ... The problem is, that I can only ever access the first value of the array I pass to the controller ( stat_kind in this case). It doesn't natter in w...

How to use eloquent ->with method on collection

You may find the question stupid. I may not be doing the research well so I thought to ask it here. I would like to know how to use ->with on collection or what is its equivalent. Here is the code: $theLastCommentOfThisPost = $post->comments->with('user')->sortByDesc('id')->first(); I would like to get something like this: Illuminate\Support\Collection Object ( [items:protected] => Array ( [id] => 19 [commentable_type] => App\Post [commentable_id] => 123 [comment] => totoototo [is_approved] => 1 [user_id] => 1 [created_at] => 2022-04-01 [updated_at] => 2022-02-04 [user] => App\User Object ( [id] => 1 [name] => App\Post [email] => totos@toto.fr ) ) ) thanks from Newest questions tag...

Installing Laravel without downloading by composer global

I'm trying to install a Laravel project. So I run this command: composer global require "laravel/installer" . After it's done, I would run laravel new project_name . So the question is, I don't want to download Laravel dependencies every time I run composer command. I want it to copy downloaded laravel from the global directory of composer to my project_dir. So, how to do that simply without downloading ? as well as for other packages. Here's is the output of composer: username@PCNAME:~$ composer global require "laravel/installer" Changed current directory to /home/alireza/.config/composer Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is now available and you should upgrade. See https://getcomposer.org/2 Using version ^4.1 for laravel/installer ./composer.json has been created Loading composer repositories with package information Warning from https://repo.packagist.org: You are using an outdated...

doesnthave() taking too long to query in laravel

I am write database query which fetch the record which does not have specific relation i am simply counting the number of records which doesn't have relation . But it is taking too long . Here is my query Consignment::doesntHave('invoice_charges')->count() But when I write query without relation it gives me quick result Consignment::count() What could be the reason . And how i can make it work? from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32HhGHY via IFTTT

PHP array_column with foreach loop

I have a table from which i am fetching some columns $records=Table::select('id','text','type')->paginate(250)->toArray(); $data=$records->['data']; I am getting output as :- array:250 [ 0 => array:4 [ "id" => 1 "text" => "text1" "type" => "A" ] 1 => array:4 [ "id" => 1 "text" => "text2" "type" => "B" ] 2 => array:4 [ "id" => 1 "text" => "text3" "type" => "C" ] 3 => array:4 [ "id" => 2 "text" => "text4" "type" => "A" ] 4 => array:4 [ "id" => 2 "text" => "text5" "type" => "B" ] 5 => array:4 [ "id" => 2 "text" => "text6...

Laravel with() not working within whereHas clousure

Suppose i have routineDetails that has one allocation and that allocation has one meeting. When i try to use this: $date='2022-11-12'; $route_details = $this->routineDetail ->whereHas('allocation', function ($q) use ($all_sub_ids, $date) { $q->whereIn('subject_id', $all_sub_ids) ->with(['liveMeeting' => function ($q) use ($date) { $q->where('join_date', $date); }]); })->get(); This query not working well. When i print foreach ($route_details as $k => $detail) { dd($detail->allocation->liveMeeting); } It returns first meeting with date another. I guess the where query ($q->where('join_date', $date); ) not hit! I want all routines that has allocation of selected subjects and that has meeting with the allocation. Is there any way to do so ? Thanks in advance....

Laravel login broke after upgrading from 5.8 to 6.20.3

I have a custom login controller that follows the code from here: https://laravel.com/docs/6.x/authentication#remembering-users if I were to do var_dump( Auth::check() ); right after the Auth::attempt it will return true and if I also try to fetch the user object it returns it perfectly inside the controller. But the problem is when I redirect, once it gets to app/Http/Middleware/RedirectIfAuthenticated.php and app/Http/Middleware/Authenticate.php the var_dump( Auth::check() ); is returning false. So somewhere in between, it's logging out my user. I've been stuck with this for a while now since everything works just fine in my 5.8 version. everything in the login controller <?php namespace App\Http\Controllers; //some models here use Illuminate\Contracts\Auth\Guard; use Illuminate\Http\Request; use Redirect; use View; use Illuminate\Support\Facades\Session; use Cache; use Jenssegers\Agent\Agent; use Validator; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illum...

How to replace li elements which have the same id in Javascript and Laravel

صورة
I have a list of sizes and colors, each color has one or multiple size and each size has one or multiple colors. What I want is when I click a certain size it should show his colors that are available in full opacity and unavailable colors to have lower opacity(0.5 opacity). So far when I click the size it just adding the available colors to the list of colors and make them as duplicates how can replace available colors to the list of colors? and have something similar to this Blade file <ul id="Sizes"> //This displays all the sizes by default @foreach($variantSizes as $variantSize) <li id="" name="size" value=""> <span ></span> </li> @endforeach </ul> <ul id="Colors"> //This displays all the colors @include('front.colors') @foreach($variantColors as $variantC) <li id="" name="color" style="opacity:0.5;" value="...

How to delete pdf/image file from storage in Laravel 5.6 on page refresh

I'm working with Laravel 5.6. In dashboard I generate a file dynamically by clicking on a hyperlink/button and show that file in same page in hyperlink. But whenever I jump from Dashboard page, want to remove or destroy that file. Can anyone please help me on it? from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3nlLul5 via IFTTT

How to validate if an array of tokens are valid, using the stored tokens in a firebase node using laravel

i am new in laravel and php, but what i want to do is issue tokens/promotion codes, to my client, this i have generated them and saved in the firebase node, then i sent the client the tokens in csv file when the client upload the csv file with the tokens they should be validated to check if the supplied tokens are valid/not yet been used, and the the valid field should be changed to false in the database, so that if they try to use the tokens again, it would not work. Bellow is my code in the controller public function reedemTokens(){ $serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/FirebaseKey.json'); $firebase = (new Factory) ->withServiceAccount($serviceAccount) ->withDatabaseUri('https://mydatabse.firebaseio.com/') ->create(); $database = $firebase->getDatabase(); $ref = $database->getReference('Tokens'); $tokens = $ref->getValue(); foreach($tokens as $tokens) { ...

get value from database in string using query builder

so in controller I am getting a value from a input form in string i.e. product_name return $request->input('product_name'); And on the behalf of this I want to get product_id of that product from database table using query builder return category::where('product_name',$request->input('product_name'))->get('product_id'); problem is, I am getting the value in array form but i want this value in string //output [{"product_id":7}] but i want it in string like 7 please help to achieve this in single line using query builder, thanks in advance from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/35lOgRd via IFTTT

Why does laravel query showing SQLSTATE[42000]: Syntax error or access violation error?

I'm working with Laravel framework 8.7.1 on Homestead. I have this query: $option_groups = DB::select('select option, opt_icon from dashboard_menu group by option, opt_icon'); When I open the page, I get this error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option, opt_icon from dashboard_menu group by option, opt_icon' at line 1 (SQL: select option, opt_icon from dashboard_menu group by option, opt_icon) What I have tried: I changed strict to false in the config/database.php file, here's my config: 'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE...

Laravel Abort and Exceptions adding debug/stack trace to API response | APP_DEBUG=FALSE

If I throw an exception in my API controllers/routes it always returns an object including the stack trace. I have set APP_DEBUG=FALSE and APP_ENV=production yet I always get a stack trace like below... Say I throw any one of these in a controllers method: throw new HttpException(410, 'Http Exception is gettting a stack trace.'); abort(404, 'Please tell me debug is not found!'); throw new UpdateResourceFailedException('Even my custom exception! How?', 422); It returns an object like this: { "message": "Message", "status_code": 410, "debug": { "line": 412, "file": "/var/www/example.com/app/Http/Controllers/OrderController.php", "class": "Symfony\\Component\\HttpKernel\\Exception\\HttpException", "trace": [ "#0 [internal function]: App\\Http\\Controllers\\OrderController->show()", ...

laravel using `new` keyword for models in controllers

I know this might be the point of view question which has no place on SO, but I am really trying to get experienced developer's thoughts. In my controllers, I don't want to use models directly. So I use services injected in a controller's constructor. In the services, we have 2 ways to initialize models. inject them in a service's constructor. use the models directly in a service's functions, like new userModel() . Option 1 explanation : I can see the advantage of the first option, due to the fact that I can test service's functions without touching database models, since I will mock the models which gives me the option that I separately test service's functions without actually doing anything on models/databases. Option 2 explanation : for the second option, all I can see is a disadvantage due to the fact that in order to test a service's function, I also have to know in advance what models(database) returns . These kind of tests are also necessary, bu...

replace the boolean with string in select query

I have the query and need to convert the boolean value into string in a select query I want to replace the boolean false to 'UnConverted' and true to 'converted' in a laravel select query $queru=DB::table('table_name')->select(DB::Raw("replace('table_name.converted',false,'Unconverted')")->get(); getting undefiened column unconverted how to replace boolean value to string from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2UhZjEM via IFTTT

Laravel API blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

I've laravel rest API application that connects with the Vue js frontend. Rest API endpoint domain is dev.mydomain.com and images are host in s3 bucket that subdomain is dev-assest.mydomain.com When the application loads the page with an image it gives below error. However, image is losing when checking the image URL Access to fetch at 'https:// dev-assest.mydomain.com/images/profiles/profile_5bb3d976f12.jpeg' from origin 'https://ift.tt/2y2OlIp' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. In Laraval backed added cors as below. Cors.php namespace App\Http\Middleware; use Closure; class Cors { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public fun...

Laravel - Vue.js routes doesn't work properly

i'm pretty new to vue.js also i'm using laravel 8 and php 7.24 what i want to do is access pages without reloading. i've set up vue.js and i have two vue components which i need to route one to another. problem is i can see the home.vue file's ingrediants but routing function doesn't work. app.js file require('./bootstrap'); window.Vue = require('vue'); import VueRouter from 'vue-router'; import routes from './routes'; Vue.use(VueRouter); const app = new Vue ({ el: '#app', router: new VueRouter(routes) }); route.js file import home from './components/home.vue'; import example from './components/example.vue'; export default{ mode: 'history', linkActiveClass: 'font-semibold', routes: [ { path: '/vue', component: home }, { path: '/vue/example', component: example } ] } home.vue fi...

How to add instruction with product in Cart

This is a fully working Cart. It can add products and calculate the quantity and total price. but I want to take instructions from User and add it with the Products in Cart. This is the body from where I am adding product to Cart. <form action=""> @csrf <input hidden name="products_id" id="products_id"> // It contains the product id <input name="instructions" id="instructions"> // Section from where I need to send instructions with each product <button type="submit" class="btn theme-btn">Add to cart</button> </form> This is the Controller: public function getAddToCart(Request $request) { $products = Products::find($request->products_id); $instructions = $request->input('instructions'); $oldCart = Session::has('cart') ? Session::get('cart') : null; $cart = new Cart($oldCart); $cart->add($products, $products-...

Laravel project installed from a external source not displaying uploaded images

I installed a laravel project from a friend on my local environment but all uploaded images are do not display. I need a solution asap. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3llKiO4 via IFTTT

Laravel-Mix 8 with run watch

I want to load vue Component in Public file using npm run watch , it gives me a message in watch dev or build ..? Node.js v14.15.0. npm 6.14.8 Laravel Installer 4.1.0 npm run watch > @ watch C:\Users\ANOOD\Desktop\Laravel&vueja\Laravel_vue > npm run development -- --watch > @ development C:\Users\ANOOD\Desktop\Laravel&vueja\Laravel_vue > cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js "--watch" The system cannot find the path specified. events.js:292 throw er; // Unhandled 'error' event ^ Error: spawn node_modules\webpack\bin\webpack.js ENOENT at notFoundError (C:\Users\ANOOD\AppData\Roaming\npm\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26) at verifyENOENT (C:\Users\ANOOD...

Object of class stdClass could not be converted to string (View: C:\wamp64\www\Application 1\resources\views\admin\soutenance\themeValide.blade.php)

for the past few days I have been blocking part of my code. Indeed I want to retrieve information from my database in order to display them in a table. web.php Route::get('admin/soutenance/themeValide', 'SoutenanceController@index')->name('admin.soutenance.themeValide'); soutenanceController.php public function index() { $themes = DB::table('themes') ->join('soutenances', 'themes.id', '<>', 'soutenances.theme_id') ->join('profs', 'profs.id', '=', 'themes.prof_id') ->join('users', 'users.id', '=', 'themes.user_id') ->select('themes.id', 'themes.title', 'profs.name AS prof_name', 'users.name AS user_name') ->where('themes.validated', '=', true) ...

How do i pass an eloquent collection to a validation rule?

I have this rule: Validator::make($data, [ 'category' => [ 'required', Rule::notIn(['news', 'article']), ], ]); The problem is that news and article are stored in another table. How do i pass the the data from that table into notIn instead? from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32x3wca via IFTTT

I am not able to show image in the Edit Modal

This is the body code and HTML which is sending data to script. @foreach($products as $product) @if($product->category == "Starters") <div class="food-item white"> <div class="row"> <div class="col-xs-12 col-sm-12 col-lg-8"> <div class="rest-logo pull-left"> <a class="restaurant-logo pull-left" href="#"><img src="images/" alt="Food logo"></a> </div> <!-- end:Logo --> <div class="rest-descr"> <h6><a href="#"...

Laravel Auth in middleware [duplicate]

I have some problems with authentication on my middleware file. I'm logging on which page is client last seen, like so: public function handle(Request $request, Closure $next) { Activity::create(['user_id' => Auth::id(), 'ip_id' => SecureAgent::getIP(), 'action' => $request->method(), 'page' => $request->path()]); return $next($request); } File in Karnel is added in $middleware; The problem is that Auth::id() is not working, only NULL. I have logged in with passport, set my token and redirect to profile page, everything is working fine except this middleware. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3lqwSAk via IFTTT

PHP | LARAVEL | EloquentDataTable datatable query always returning 10 rows to the max

صورة
I'm trying to show the list of productOrders based on an order ID within one of my view. Here's the code snip from my app/Datatables/ProductOrderDatatables.php which i use to pull the list from my database table called "product_order" : public function dataTable($query) { $dataTable = new EloquentDataTable($query); $columns = array_column($this->getColumns(), 'data'); $dataTable = $dataTable ->editColumn('price', function ($productOrder) { return getPriceColumn($productOrder); }) ->rawColumns(array_merge($columns)); return $dataTable; } Here's my query function within the ProductOrderDatatables.php : public function query(ProductOrder $model) { return $model->newQuery()->with("product") ->where('product_orders.order_id', $this->id) ->select('product_orders.*')-...

Laravel Downloadable File Not Getting Download

I have connected my laravel project with my network folder and connected it to a local folder, code to upload it to the network folder $destinationPath = Storage::disk('shared')->url('uploads/files/') . $name; so its a console command while running pdf files being uploaded to my network drive I need is to download such uploaded files through my view example file location would be like this file://laptop-lo2am2jp/storage/uploads/files/aa.pdf so while uploading I am inserting it to a database column, so I am passing the URL to view view code <div class="col-md-3"> <a href=""> <button type="button" class="btn btn-primary">View pdf</button> </a> </div> when I click it loads with my localhost URL and saying no such files http://localhost:8000/laptop-lo2am2jp/storage/upload...

How to fix on Laravel, Maximum function nesting level of '256' reached, aborting

I have a shared form that I am using to save or update a post record. I am using optional($post)->postimage to check if this variable exists in case of update (because I must display it to let users delete if they want it). I added a new column which is in hasOne relationship with my main model I am saving data. I get this error: Maximum function nesting level of '256' reached, aborting! and laravel is targeting the line where I have @if (optional($post)->postimage != null) ... If I comment this line, my form works perfect as before. But I don't want it like that, because there are existing posts and I want to let users add this data if they want it, like they can add to new record. I have many existing other relations on my model, including hasOne before the new one I added. What is the problem? what am I doing wrong? How to fix this ? thanks from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3klcoIh via IFTTT

I am encountering a permission error in Laravel. Any suggestions?

This is the error: file_put_contents(/var/www/html/{project_name}/public/temp/ttfontdata/dejavuserifcondensed.mtx.json): failed to open stream: Permission denied. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2JQ8ydv via IFTTT

If Possible to Read existing PDF content position and add the some content after over the existing content in laravel?

Laravel Package: "setasign/fpdi": "^2.3", "setasign/fpdf": "^1.8" $pdf = new \setasign\Fpdi\Fpdi('L','mm','A4'); $pageCount = $pdf->setSourceFile(public_path().'/'.$url); $pdf->setFont('Arial', 'B', 10); for($i = 1; $i <= $pageCount; $i++){ $tplIdx = $pdf->importPage($i); $pageDimensions = $pdf->getImportedPageSize($tplIdx); $pdf->addPage($pageDimensions['orientation'], $pageDimensions); $pdf->useTemplate($tplIdx); } If It Possible read the content of the last page and get after page content ordinate of the current position. then Write new content without add new page or whitespaces from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3kegZvD via IFTTT

Laravel 5.0:CSV created using fopen() and Upload on AWS S3 Bucket Using Storage

صورة
I am working on two things: Creating the CSV file using fopen() and inserting the data from mysql and Close the File. Now, need to upload that created file into AWS S3 bucket directly. Now, I am able to created the CSV file, but unable to upload the file into AWS S3 bucket. Laravel PHP Code: public function download() { $headers = array( "Content-type" => "text/csv", "Content-Disposition" => "attachment; filename=auditsystem.csv", "Pragma" => "no-cache", "Cache-Control" => "must-revalidate, post-check=0, pre-check=0", "Expires" => "0" ); $columns = array( 'S.no', 'State Name', 'State Code' ); $audit_params = DB::select(DB::raw("select * from table_state_codes")); $callback = function() use ($audit_...

Migration and seeders in Laravel

I'm trying to seed my database in laravel but i keep getting the following error when i run: php artisan db:seed Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'post_id' in 'field list' (SQL: insert into `posts` (`title`, `name`, `body`, `post_id`, `updated_at`, `created_at`) values (Karlie Block, Angela Schimmel, body2, 1, 2022-11-08 21:29:42, 2022-11-08 21:29:42)) Here are my classes: create_posts_table.php: <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreatePostsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('posts', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('title'); $table->mediumText('body'); $table->string('name'); ...

Laravel ajax return excel instead of binary string

صورة
using laravel I tried to create excel and add data on it and download(export) it as excel file on client side but instead of excel file to be downloaded it return string. can someone help me please. thanks in advance. My controller code use Maatwebsite\Excel\Facades\Excel; public function exportreport(Request $request){ $file = "users.xlsx"; return Excel::download(new reportExport, $file); } my export code use App\cqqeuryformModel; class reportExport implements FromCollection { public function collection(){ return cqqeuryformModel::all(); } } return is string instead of excel file console.log console.log from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3n8R36j via IFTTT

Slide To Unlock slider on Login Form will not POST or login

My project is in Laravel 5.4, and the Login button beneath it is the original working login button, as you can see it posts and attempts to login correctly: Console when pushing Login button (Successful Login Attempt) So as you can see I've added a slider to unlock and want to use that instead of the Login button. Here's what I have so far: <!DOCTYPE html> <html> <head> <title>My site test</title> <meta name="csrf-token" content="" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></scrip...