المشاركات

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

Laravel update from 5.1.46 to 5.2.* php artisan Segmentation fault

I'm working to update a Laravel project from 5.1.46 to 5.2.*. After I followed the steps from here https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0 I have ran the command ./composer.phar update I receive the follow error when the composer tries to run php artisan clear-compiled Segmentation fault (core dumped) I tried to run manually the command php artisan clear-compiled -vvv But I have exactly the same output. Do you have any idea how can I debug what is causes this? This appears with PHP 5.6. Also I've tried to use PHP 7.4, but it looks like the computer runs out of memory. For some reason the artisan is taking the entire memory of the computer, until the computer freezes. Thanks! from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/370qeJ7 via IFTTT

Expected response code 354 but got code "503", with message "503 5.5.1 RCPT first. w15sm3670747wrs.80 - gsmtp "

I am using Laravel 5.8 and I am trying to send email from system using below setting. when is send email one by one its working fine but when I send bunch of marketing email together it stopped after sending 20 email and giving me below error. I am using below setting in .env. MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=465 MAIL_USERNAME=my user name MAIL_PASSWORD=my gmail app password I am getting below error after sending 20 emails Expected response code 354 but got code "503", with message "503 5.5.1 RCPT first. w15sm3670747wrs.80 - gsmtp " also I tried with TLS but it's giving me same error after 20 emails... from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2vahNOe via IFTTT

Extend Office365 Login Function to mobile applications

I have built a web portal using laravel and integrated office365 login using this package moathdev-zz / office365-Laravel . It's working great, and now I'm building a mobile app with that portal as backend. I need to extend the office365 login to the mobile application. I have looked into it, and I think there are three options: PHP Curl: send a post request with user email and password then sign them in the portal using Auth::login once verified. My problem with this option is that I don't know how to format the post request. Web login put a link in the app that takes the user to office login. My problem with this option I don't know how to redirect them back to the app once logged in. App direct login There are office365 packages for react native. My problem with this option is that I don't know how sign the users in the backend. Thank you all from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/380bLON via IFTTT

Laravel memcached errors after random time

Hello I am using memcached in laravel application 5.8. After some time the error is: production.ERROR: Invalid argument supplied for foreach() Code in controller is: $page = \Request::get('page', '0'); Cache::tags('posts')->remember('page-'.$page, 15, function(){ return Post::orderBy('created_at', 'desc') ->paginate(20); }); $posts = Cache::tags('posts')->get('page-'.$page); The error comes, because of the @foreach loop in the view. When I get the error, I can fix it by restarting the server, but this is not really a good solution. How can I prevent this issue and still use memcached ? I am sure that it comes from the cache, because if I change the cache driver to array than the error is gone. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/384vpJz via IFTTT

syntax error, unexpected '​' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) Laravel

I have a shop model you can see it <?php namespace App; use Illuminate\Database\Eloquent\Model; use TCG\Voyager\Traits\Spatial; class Shop extends Model { use Spatial; ​ protected $spatial = ['lat']; } but it consistently giving me error after writing these lines of code syntax error, unexpected '​' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3bqmB2O via IFTTT

How can I get response from guzzle in Laravel 5.3

I try like this : $res = $client->request('POST', 'https://api.orange.com/smsmessaging/v1/outbound/tel:+phone/requests/', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization'=>'Bearer '.$token, /*'Content-Type' => 'application/x-www-form-urlencoded',*/ ], /*'form_params' => $body ,*/ 'json' => [ 'outboundSMSMessageRequest'=>[ 'address'=> 'tel:+$phone', 'senderAddress'=>'tel:+phone_rec', 'outboundSMSTextMessage'=>[ 'message'=> 'Hello test!' ] ]], 'debug' => true, 'verify...

handle fcm display messages and data messages by using laravel rest api in android java

how to handle it in android fcm please share any suitable solution i want to reslove issue of fcm on backround and on foreground $payload = [ 'to' => $user->device_token, 'collapse_key' =>'test message', 'data' => [ 'title' => '', 'message' => $push_message ], 'notiification' => [ 'title' => '', 'message' => $push_message ] ]; how to handle it in android fcm please share any suitable solution i want to reslove issue of fcm on backround and on foreground from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2S0JxxL via IFTTT

laravel How to change column name while using relation ships

i have following function in my notes controller ,which is working fine public function getAllNotes($modelName, $modelID) { $modelNameCamelized = self::camelize($modelName); $modelClass = FTM::getClass("App\\Models\\" . $modelNameCamelized); $obj = $modelClass::with(['notes'])->find($modelID); if (!class_exists($modelClass)) { return response()->view('errors.404', [], 404); } if ($obj) { return $obj; } } the result from it is in json as below { "PersonID": 3, "UserID": 14, "TitleID": 2, "is_participant": 1, "is_trainer": 1, "is_free_lancer": 0, "LastName": "Patel ", "FirstName": "Rupesh", "NickName": null, "Email": "patel.rupesh.009@gmail.com", "Birthdate": "2022-10-30", "Age": 1, "Gender": "1", "is_dnd": ...

Session data I've set disappears after a period of inactivity

I may be doing this the wrong way, or there may be a better way to do it.. Upon login I'm setting some session data: session(['api_token' => $user->api_token]); session(['season' => Season::find($request->season)]); session(['centres' => Centre::where('active', 1)->get()]); I call it like so... session('season')->name .env file: SESSION_LIFETIME=9999999999 This works great for a while, but if there's a period of a few hours of activity (I haven't timed it exactly), then the session data I've set gets lost, I have to log out then back in to set the session data again. However, the user still remains logged in, I can pull Auth data perfectly fine. What is going on here? from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/38fn6ug via IFTTT

Laravel Array to string conversion not working

I want to update a totcosty field in the User table but it is throwing this error everytime and it is not updating the field this is the function for execution: public static function cost(){} $user_id = auth()->user()->id; $user = User::find($user_id); $total = Helper::totcost(); //dd($tot_amt); $user->totcosty = $total; $user->save(); } from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2SpGUo3 via IFTTT

Set background-color to div from form in another blade

My project contains index.blade.php and create.blade.php. In create.blade.php is a form for creating divs that are listed in the index.blade.php, through the form I need to pass the background-color for each div made, options red, yellow and green color. My create.blade.php code: <form action="" method="post"> @csrf <label for="name" style="padding-right:20px">Name</label> <input type="text" id="name" name="name" style="padding-right:50px; margin-bottom:10px" placeholder="Name"><br> <label for="supplier" style="padding-right:2px">Supplier</label> <input type="text" id="supplier" name="supplier" style="padding-right:50px; margin-bottom:10px" placeholder="Supplier">...

Jquery DataTable not working on report section

The datatable not working on report section: the jquery and datatable plugin loaded and no error on console. "use strict"; var app = { main: function () { "use strict"; app.execute(); app.pluginn() }, execute: function () { var table = ""; table = $('.table').DataTable({ processing: true, dom: 'Bfrtip', buttons: [ { extend: 'excel', exportOptions: { columns: ':visible' } } ], 'rowCallback': function (nRow, aData, iDisplayIndex) { $("td:first", nRow).html(iDisplayIndex + 1); ret...

How to do arithmetic operations in Laravel blade view?

I want to do subtraction operation inside Laravel blade view. I knew it was the wrong approach I need to do it from controller,but can someone give me the proper solution to do it directly inside blade view? Note : I am a newbie to programming. Here is my code @if(!empty($receipt_details->total_due)) <tr> <th> Customer Old Due </th> <td> - </td> </tr> @endif from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/374KnOc via IFTTT

Getting issue while migrating the columns in laravel

صورة
I am facing the below issue when trying to migrate the column in laravel. I have upgraded the laravel to 5.8 after that I am getting this issue . I have tried everything what others has suggested in their answers and blogs but still getting the same issue. Please help me. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3bbCJVP via IFTTT

Get count in Laravel after grouping without using get()

$countQuery = $countQuery ->groupBy("something"); $totalCount = $countQuery->get()->count(); In $countQuery there are joins also. I want to get the final count without get() from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/397OY3y via IFTTT

How do i create a query in Laravel 5.2 query builder, group by

I have the following sql query. $s2 = "SELECT id FROM transaksi WHERE tarikh='$tar' AND idPekerja IN (SELECT idPekerja FROM pekerja WHERE '$tar' BETWEEN mula AND tamat $samb) GROUP BY idPekerja,tarikh"; $r2 = mysql_query($s2) or die(mysql_error()); $jumHadir = mysql_num_rows($r2); return $jumHadir; from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/39ghsYX via IFTTT

How to make on change selection using array of textfield name?

I had add/remove fields dynamically using jquery in laravel 5. In the dynamic field, there is a selection field which will autofill the other dynamic textfields. However, the dynamic selection is named as an array 'pegawai[]'. If using id, it will be easier. But I don't know how to make on change selection using array textfield name. This is the code for the fields: <div class="table-responsive"> <table class="table table-bordered" id="dynamic_field"> <tr> <td col-lg-3><select id="name[]" name="name[]" class="form-control"><option value="">Nama Pegawai</option><?php foreach($pegawai as $key => $value):echo '<option value="'.$key.'">'.addslashes($value).'</option>'; endforeach; ?></select></td> <td><input type=...

How passing data to multiple blade in laravel and with single route

i have tried to passing data to multiple blade in controller but get error. Here bellow my code public function index() { $news = DB::table('beritas') ->select('id','judul_berita','created_at') ->get(); return view (['berita.daftar-berita', 'more-menu.berita'])->with(compact('news')); } from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2S2nmY4 via IFTTT

Getting foreign key constraint error 1215 while building from laravel migrations

Getting this error 1215. Though the type and key name is exactly correct. I am linking the column having data-type = varchar though it is very rare to use varchar column as foreign key. But I need to add this only. Given below are two tables getting created and their schema is shown. This is the parent table. public function up() { Schema::create('resources', function (Blueprint $table) { $table->increments('id'); $table->string('type'); $table->timestamps(); $table->softDeletes(); }); } This is the child table. public function up() { Schema::create('active_subscriptions', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('resource_id'); $table->string('resource_type'); $table->dateTime('start_date'); $table->dateTime(...

How to change the timezone manipulate the timestamp of created_at

I have an eloquent query that I would want to change the created_at to subtract 2 hours. The query is AirtimeTransaction::select('airtime_transactions.id', 'airtime_transactions.created_at', 'airtime_transactions.request_id', DB::raw('IF(airtime_transactions.result_desc IS NULL or airtime_transactions.result_desc = "", "Failed", airtime_transactions.result_desc) as result_desc')) ->groupBy('airtime_transactions.id'); I would like to subtract two hours from the answer to airtime_transactions.created_at Anyone assist here from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3836whp via IFTTT

Invalid argument supply for foreach in laravel for json response

Hi I am working on razorpay integration and after succesful payment when i try to save the details to the database.i am sending the details through ajax.and in controller when i try to use foreach and look in console i always get the error invalid argument supplied for foreach statement. this is the script after successful transaction <script> function demoSuccessHandler(transaction) { // You can write success code here. If you want to store some data in database. $("#paymentDetail").removeAttr('style'); $('#paymentID').text(transaction.razorpay_payment_id); var paymentDate = new Date(); $('#paymentDate').text( padStart(paymentDate.getDate()) + '.' + padStart(paymentDate.getMonth() + 1) + '.' + paymentDate.getFullYear() + ' ' + padStart(paymentDate.getHours()) + ':' + padStart(paymentDate.getMinutes()) ); $.ajax({ method...

`Row `1` must be array` in laravel

I am trying to import csv file in laravel with help of maatwebsite . I have query which is bringing data from two table both have relation with each other. it is exporting only one table data when I try to fetch data of both tables it gives me an error of Row 1 must be array $data = SaleOrder::where('id',$id)->with('customers')->get()->toArray(); return Excel::create('Packlist Sale Order '.$id, function($excel) use ($data) { $excel->sheet('mySheet', function($sheet) use ($data) { foreach($data as $customer) { $sheet->fromArray($customer['customers']); } $sheet->fromArray($data); }); })->download('xlsx'); I want fetch data of both tables in csv file from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/384Vjgc via IFTTT

Update Data Using Modal Bootstrap in Laravel

Please anyone can help? i wanna use modal dialog as update data, especialy for laravel 5, i've datatable displaying chosen data and didn't put on row by row ( < td > ) example i wrote in the below blade, and how to display data in modal dialog wihout array datatable or randomly display datatable? here the blade for table: @if(session('notifaction')) <div class="alert alert-success" role="alert"> <button type="button" class="close" data-dismiss="alert">&times;</button> </div> @endif <div class="row"> <div class="col-6"> <h1>Data Kinerja</h1> </div> <div class="col-6"> <button type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#tambahhki"> + Tambah Data ...

how to set the columns in an excel using Maatwebsite using laravel 5.4

Hi i have this download csv. Now my problem is i want to get the certain columns for my excel file not all fields from the database to be pulled to csv. Now my download csv works good and could download the data. Now i want that only certain columns to be displayed into my csv file. the getCell code wont work. This is my code below //download csv all pending public function downloadExcelAllPending($type){ $data = BookingHistory::orderBy('checkin_date', 'desc')->get()->toArray(); return Excel::create('booking_history', function($excel) use ($data) { $excel->sheet('mySheet', function($sheet) use ($data) { $sheet->getCell('A1')->setValue('first_name'); $sheet->fromArray($data); }); })->download($type); Now this line of code here $sheet->getCell('A1')->setValue('first_name'); won't work. Can someone help me figured thi...

Maatwebsite is not fetching data of relational table in laravel

I am try to export csv file with maatwebsite. Query I write is fetching data of other table also with which it is having relation. but it is exporting csv file only with one table data. $data = SaleOrder::where('id',$id)->with('customers')->get()->toArray(); return Excel::create('Packlist Sale Order '.$id, function($excel) use ($data) { $excel->sheet('mySheet', function($sheet) use ($data) { $sheet->fromArray($data); foreach($data as $customer) { $sheet->fromArray($customer['customers']); } })->download('xlsx'); I want to fetch data of both tables in csv file from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ubwcK7 via IFTTT

nginx: how to serve file from a subfolder of root?

My local dev env is configured on nginx as is server { listen 80; server_name project.local; root /var/www/project.local/public; charset utf-8; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { fastcgi_pass unix:/run/php/php7.2-fpm.sock; fastcgi_index index.php; include fastcgi_params; # Questi due parametri sono fondamentali # per le app Laravel # => https://serverfault.com/a/927619/178670 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } location ~ /\.(?!well-known).* { deny all; } } The problem is only about a folder /fon...

Object of class App\city_cost could not be converted to int

I am using laravel helpers function. I am passing an argument to it that contains a value which I want to use to update the user table a field cold totcosty. But Everytime it is showing me this error. This is the helper function Class Helper{ public static function cost($citycos) { $user = new User(); $user->totcosty += $citycos; $user->update(); } } This is where I passed the value public function store(Storecit $request) { $citycos->cost=$request->input('city_cost'); $citycos->save(); $test = Helper::cost($citycos); } from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/380Y2Y4 via IFTTT

Send my ajax text field to php input value

Hi am trying to send my ajax value into my php field but when i try to make changes i always gets the blank input field this is my form <div id="paymentDetail" style="display: none"> <center> $count=0; <form method="post" action=""> @foreach($product as $input) <div>Product: <span class="product"><input type="text" name="product[]" value=""></span></div> <div>paymentID: <input type="text" class="paymentID" name="txn_id" value=""></div> <div>paymentDate: <span class="paymentDate" name="date"></span></div> @endforeach <div>Print: <span><input type=...

how to make the controller redirect results to an outside link or return a script alert in LARAVEL

hello I want to make a validation here in my table there is a column to store the data in the form of url to another link, here I want to make validation if the data exists then it will point to the link in $ get-> url_drive if it's not there then I want to display it in the form of a script for the user and redirect back this my controller $id = $request->input('id'); $type = $request->input('type'); $name = $request->input('name'); $type = strtolower($type); $name = strtolower($name); $get = DB::table('users.user_connects')->where([ ['user_id',$id], ['type',$type], ['name',$name] ])->first(); if(isset($get)){ // here i am confused } from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/38bOZ6s via IFTT...

Laravel function not reading the $id

In my web application I have added the cache method. But the problem is its not reading the specified $id which is passing in the function. So that its throwing error like : ErrorException: Undefined variable: id What to do if anyone suggest any answers will be helpful. Here is the code -> public function relatedstory($id) { $key = $id; $cacheKey = $this->getCacheKey($key); return cache()->remember($cacheKey, Carbon::now()->addDay(1), function () { $story = $this->_story->findOrFail($id); $tags = $story->tags->random(1)->pluck('tag_id'); $storyIds = StoryTagItem::whereTagId($tags)->get()->random(4)->pluck('story_tag_id'); $relatedStory = []; foreach($storyIds as $storyId) { array_push($relatedStory, $this->_story->findOrFail($storyId)); } return StoryListResource::collection($related...

Laravel Type error: Too few arguments to function Illuminate\Database\Eloquent\Model::setAttribute(), 1 passed in

i want to ask about error "Too few arguments to function Illuminate\Database\Eloquent\Model::setAttribute(), 1 passed " this is my code : Dataanggota.php class Dataanggota extends Model { protected $table; protected $primaryKey = ""; protected $casts = ['cno' => 'string']; protected $guarded = [ ]; public $incrementing = false; public $timestamps = false; public $rules = array(); public $nicename = array(); public function __construct(array $attributes = []) { parent::__construct($attributes); $this->table = config("consyst.dataanggota.table"); $this->primaryKey=config('consyst.dataanggota.primary_key'); $this->rules = array( ); } DataAnggotaControllers.php public function insertBank() { // dd($this->request->cno); if ($this->request->ajax()) { try { $metas = new Hubban...

Store remember token upon user creation

Currently the laravel remember token work if you approver it on email. How can I store it at the same time of creating the user? Here's my code $user = New User; $user->username = $request->username; $user->password = bcrypt($request->password); $user->role = $request->role; $user->remember_token = '' //I don't know how $user->save(); Thank you for your help. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/371Ntm6 via IFTTT

Setting DB connection when resolving route models

I have read only routes such as /api/orders/{order} and I would like to point the model to the specific reader connection at the time Laravel hydrates the model in the route before it passes it into the controller such as public function show(Order $order) { ... } I don't want it to affect all routes. How would I do this? from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GUSv9x via IFTTT

Laravel writes in the root of my project rather than s3

I was trying to make a connection to s3 bucket in laravel and I was testing the connection so I made a simple function that writes a file in 's3' storage, but turns out that laravel is actually writing the files locally in the root of my code!! I already made an s3 bucket and made an Iam user with the needed permissions and I put the secrets in .env file but it's not working, if I try any other random disk driver it shows me an error and if I use the 'local' driver it's working fine (by writing the storage directory of the project). However, whenever I try to use s3, it doesn't show me any error but it writes in the project root! my simple method in web.php : Route::get('/test',function(){ Storage::disk('s3')->put('hi.txt','hello'); return Storage::disk('s3')->get('hi.txt'); }); filesystems.php: <?php return [ /* |-------------------------------------------------------------------------- | Default Fi...

How do i get result by comparing Date column and Time column when Date and Time column are separate columns in Laravel

I want to fetch events based on their end_date and end_time from events table. So i need to fetch those events only which are in the future. So if current date and time is greater than end_date and end_time then then it should not fetch those records because the the date and time has passed. I have done so far : $today = Carbon::now(); return $query->where('end_date', '>=', today()->format('Y-m-d')) ->where('end_time', '>=', $today->toTimeString()); But this code will not work as expected. How can i write a query where i will be able to check first if date is today then only check time. Thanks in advance. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2uk2GSb via IFTTT

How to put file viewjs in function loadView of DOmPDF laravel?

I want to generate a PDF and I use DomPDF in my project Laravel. I search on website and I didn't find the solution. How to generate a PDF with DomPDF with a file.vue ? Instead of template blade ? Thank you for your answer !! from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/36SNcBT via IFTTT

Larevel Relationship from array in database

I was wondering if you could help with a laravel relationship. I will try to explain as best i can. I have a two tables: Alerts Schema::create('alerts', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('user_id'); $table->float('price_low')->nullable(); $table->float('price_high')->nullable(); $table->json('conditions')->nullable(); $table->softDeletes(); $table->timestamps(); }); Conditions DB::table('conditions')->insert([ ['condition_value' => 'New'], ['condition_value' => 'Second Hand'], ['condition_value' => 'Ex Demo'], ]); The condition field 'conditions' stores an array like this: [{"condition_id": 1}, {"condition_id": 2}] I am trying to define a relationsh...

Using storage_path from another Laravel app

I have an application that uses two different Laravel apps talking to the same database. App 1 is called BUILDER and App 2 is called VIEWER. In production I use S3 for storing files submitted within the application. For local development I use the storage/app/public folder in BUILDER. The local dev setup is that BUILDER runs on localhost:8000 and VIEWER on locahost:8001 Now here comes my problem. In production both apps use the same S3 bucket for storage. So somehow I need to set this up similarly for local development. The BUILDER is working fine, uploading and reading its files from the storage/app/public folder with FILESYSTEM_DRIVER=public in .env The VIEWER is also reading these files fine, creating correct URL's after I added a new disk in the config (BUILDER_URL is set in .env to localhost:8000 which is the URL for the BUILDER) 'builder_public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), ...

Select and generate insert statement from database with laravel coding

Hello there hope you will doing well. I want to select table records and then generate insert statements from that selected tables and save those insert statements in a text file how i can get this in laravel I have search alot but could not find any solution.Please help me. Thanks in advance. Blade code. <form id="tblExportsForm" autocomplete="off"> <fieldset> <legend>Database Export Synchronization</legend> <div class="form-group"> <label class="cus-label">Select Table(s) <span class="badge badge-success circle"></span></label> <select name="tblExportSelect[]" id="tblExportSelect" class="form-control" required multiple> <option value="">Select an option</option> @foreach($tables as $key => $table) <option value="" dat...

Having problems to pass searched data from controller blade file using ajax in laravel

This is my controller method in Admin Controller , this method receive the search input but i am facing problems to pass output data to the view file public function action(Request $request) { if($request->ajax()) { $students=Student::where('name','LIKE','%'.$request->search."%")->paginate(5); $data = $students->count(); if($data > 0) { $output=$students; } else{ $output=$students; } return view('search' compact('output')); } } Here is the ajax in view file ( search.blade.php ) <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script type="text/javascript"> // $(document).on('keyup', '#search', function(){ $('#search').on('keyup',function(){ $value=$(this).val(); $.ajax({ type : ...

I want to show image from storage

Hi I'm currently working on legacy laravel code I want to show the image on the page from storage how can i do it ? The code i have in web.php Route::get('files/payment/{filename}', function($filename) $filePath = storage_path().'/payment/'.$filename; if (!File::exists($filePath)) { return Response::make("File does not exist.", 404); } $fileContents = File::get($filePath); return Response::make($fileContents,200); from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GMIN9c via IFTTT

Query SQL in queryBuilder

Anyone knows how to do this sql query in query builder? select i. , s. from usersAPP i cross join news s left join newsInteractions si on si.DNIUser = i.DNI and si.idNews = s.id where si.DNIUser is null; I tried this but doesn't work $no_vis_no_like= DB::table('news') ->crossJoin('usersAPP') ->join('newsInteractions', 'news.id', '=', 'newsInteractions.idNews') ->join('newsInteractions', 'usersAPP.DNI', '=', 'newsInteractions.DNIUser') ->count(); from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/31n7P8r via IFTTT

How to let ID autoincrement start from certain number in Laravel Migration

I want to write a Laravel Migration auto increment ID as a primary key. I want to start this ID with a another value rather than 1. How can I do so ? The migration up() function: public function up() { Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->string('email')->unique(); $table->string('phone'); $table->rememberToken(); $table->timestamps(); }); } from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3b7WP36 via IFTTT

Omnipay Paypal Express Checkout Error: Security header is not valid

I have searched around stack overflow and google in general and have not found a problem similar to mine. The problem is whenever setTestMode() method is used the error "Security header is not valid" pops up. But if I remove setTestMode() and just keep the setUsername(), setPassword(), and setSignature() methods, it goes through and redirects straight to paypal (Live Paypal). So afaik the problem should lie in how I'm using setTestMode and not about incorrect Api Creds as most "Security header is not valid" errors are about. I am currently using Laravel 5.8 with Omnipay/paypal using Paypal Express Checkout Here are the files that were used Paypal.php public function gateway() { $gateway = Omnipay::create('PayPal_Express'); $gateway->setUsername(config('services.paypal.username')); $gateway->setPassword(config('services.paypal.password')); $gateway->setSignature(config('services.paypal.signature')); $ga...

Browser timeout issue for larger csv files in Laraval

I have a requirement like uploading large csv file and browser shows timeout after some time. I am coding in PHP Laraval. Please help me with some solution. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2u5LPml via IFTTT

Retrieve data from pivot and their related tables laravel in single query

I have two tables with many to many relationship as follows Buyer - id - Name Book - id - BookName Book_Buyer - id - book_id - buyer_id - Quantity - Price I need to retrieve Name , BookName , Quantity and Price from this relation through a single query. I need to format the response into JSON where I can show them to yajra datatable How can I do it? I tried using an array where I pushed them through a single array but I didn't get the result in to the datatable. $get = Buyer::all()->each(function ($buyer) { $buyer->books->map(function ($books) { return $books->pivot; }); }); I tried the above solution but it gives me the whole values from database as in relation with pivot. Can anyone suggest the way to do it from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GQHoyo via IFTTT

How to use SwiftMailer plugins in laravel mailable

Here's the SwiftMailer plugin sample code, but it didn't use the laravel mailble. $decorator = new Swift_Plugins_DecoratorPlugin($replacements); $mailer->registerPlugin($decorator); $message = (new Swift_Message()) ->setSubject('Important notice for {username}') ->setBody( "Hello {username}, you requested to reset your password.\n" . "Please visit https://example.com/pwreset and use the reset code {resetcode} to set a new password." ); from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/31hxGhY via IFTTT

Receive Notificatoin Pusher + Echo in Laravel

I am trying to receive notification using echo + pusher. I can post to pusher and pusher console receive the event and channel but i can't get this data on laravel. I read many document none of work for me. WebNotification Class // Notification file private $subscription; public function __construct($data) { $this->subscription = $data; } public function via($notifiable) { return ['database','broadcast']; } public function toBroadcast($notifiable) { return new BroadcastMessage([ 'data' => $this->subscription, 'count' => $notifiable->unreadNotifications->count() ]); } Account Model <?php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; class account extends Model { use Notifiable; public function receivesBroadcastNotificationsOn() { return 'accounts.'.$this->id; } } MyNotification // To call event to sen...

laravel shareable form URL

I need to find a way to create a shareable form URL where I can use it to send it to the client(no authentication needed) and the client can fill the form and submit and it would show in my database. My problem with this is not creating the form my problem is how can I create a new shareable form URL that is unique and can only be used once? from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/392kVum via IFTTT

How to check the last chunk?

i'm using the chunk method chunk to get big data but i need to know the last chunk, because i'm punting the data in file, and at the last chunk i don't want to add something to the file , so i need to know the last chunk DB::table('users')->chunk(100, function($users) { //how to know if it's the last chunk or not ? foreach ($users as $user) { // } }); is their a way to know the last chunk from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ufjZDU via IFTTT

Displaying Datatables data from a different table

I want to display datatable data from another table inside my master form data. Company Master File has Employees Tab which is displayed via datatables. Employees table linked to company via company_id The relationship already is defined in all Models relevant, I want to use Datatables now to display the employees within the [ Company Employees Tab ] inside [ Company Master ] from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2thEcZk via IFTTT

Laravel - Executing command in controller, track progress

I have a system where the user can download a composer package with the click of a button. The installation goes fine and the package gets installed but there is no way to track the progress of the command. I want to track the progress and show it in a progress bar but I don't quite know how to? Links <a href="" class="badge badge-light fa-1x">Install</a> <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div> </div> <a href="" class="badge badge-light fa-1x">Uninstall</a> Routes Route::get('package/install', 'PackageController@install')->name('install_package'); Route::get('package/uninstall', 'PackageController@uninstall')->name('uninstall_package'); Controller public function install() { $p...

Eloququent: relationship from relationship

Have three tables / models: Clients: id - client Brands: id - brand BrandModels: id - model - brand_id BrandModelClients: id - brandmodel_id - client_id I would like to get a "group by" clients list based on the brands in the cleanest way. Right now, I'm doing it in a dirty way. So the point is that if I have a client who has three different cars of the same brand, get just one client element. from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Okwwgf via IFTTT

How to implement loop on fetched data though group by clause in laravel?

I am trying to implement loop on fetch data but it is giving error that property does not exist. $SaleOrderProducts = SaleOrderProducts::where('sale_order_id', $id)->get()->groupBy('purchase_order_product.products.id'); I tried this foreach($SaleOrderProducts as $product) { return $product->products->id; } When I just return $products foreach($SaleOrderProducts as $product) { return $product; } then it returns data in this format [{"id":6,"sale_order_id":2,"product_id":5,"purchase_order_product_id":5,"qty_taken":75,"created_at":"2022-01-31 19:04:05","updated_at":"2022-01-31 22:33:41","purchase_order_product":{"id":5,"purchase_order_id":1,"product_id":5,"measurement_unit":"Cartons","expiry_date":"2022-02-01","created_at":"2022-01-31 19:02:03","updated_at":...

Call to a member function file() on array Error when try to send multiple file()

Laravel says I sent file : Files product [ { "mainpic": { "pathname": "/tmp/phpxJefSH", "size": 209982, "mimeType": "image/jpeg" } } ] Now I tried to get image and upload it with this code in Controller : $pic = $this->uploadImages($req->file('product')[$key]->file('mainpic')); Laravel logged this error : Call to a member function file() on array and It's from that line of code. How can I get an image from this uploaded version in the form? from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3aXTIuF via IFTTT