Questions tagged [laravel-5]

11955 questions
1

votes
1

answer
10k

Views

Laravel 5.4 Api Route 401

I built a new laravel 5.4 project. I tried to do the steps below in my api route, but somehow they do not work. In my app.js file I have this ajax call: $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'), } }); $.ajax({ url: 'api/postStream', type: 'post', data: {...
utdev
0

votes
0

answer
6

Views

Laravel 5.4 crons to execute my commands not executing on server(cpanel)

Created and registered test commands as shown below in the app\console\commands\Update.php file: ` //signature protected $signature = 'Thumi'; ……. //handle to execute console command public function handle() { $user = User::findOrFail(6); $user->update(['fname' => 'kennnn']); } app\console\K...
Kenneth mwangi
1

votes
3

answer
1.5k

Views

Laravel Join returns duplicates data

Im trying to get top five players and I use join to get each players information base on personId, but my query returns duplicate data. I cant figure out why it duplicating the record, any help would be much appriciated. Thanks DB::table('person_competition_statistics as pcs') ->where('pcs.competiti...
PenAndPapers
1

votes
2

answer
1.6k

Views

How copy entire directory from one folder two another using laravel 5

May be it's so easy but I couldn't find any proper answer in google or here!! I did use \File::copyDirectory('public/' . $token . '/cover/', $folderName . '/cover/'); but there's no different!! This is where I found above solution. Do you know how can I copy entire directory from one folder to anot...
Kiyarash
1

votes
1

answer
808

Views

How to return array with custom key mapWithKeys?

This is code that iterate collection in Laravel: $usersData = $users->mapWithKeys(function ($item) { return [$item->id => array("name" => $item->name, "email" => $item->email, "id" => $item->id)]; }); I tried to get array $usersData with custom key and value as array. But in result I get this: array...
OPV
0

votes
0

answer
4

Views

Can i use eloquent ORM and query model in one place (one model)?

I want using Eloquent ORM and Query Builder in one place (one model), Thanks
Nasir Usman
1

votes
1

answer
673

Views

lumen passport login using username or email

Currently, I am working or lumen(Laravel's microframework), I have integrated passport in that application for user login. I was stuck when the client told me that we need to log in with both, the username or email! I have done that by changing lumen passports internal code as below vendor/laravel/p...
Prateik Darji
1

votes
1

answer
2.1k

Views

Laravel 5.5 Permissions - User does not have the right roles

I'm trying to find a solution in a use case where the admin user does not have the assigned role. In dashboard view it doesn't render the url for users, while if I directly access the dashboard/users, I get: Spatie \ Permission \ Exceptions \ UnauthorizedException user does not have the right roles...
sniafas
0

votes
0

answer
5

Views

Thumbnail images not showing

i will be glad if anyone can help. code line OUTPUT
Sbreu
0

votes
1

answer
15

Views

Laravel 5.7 - Login doesn't log the user

I started learning about Laravel 3 days ago and I reached a problem which I cannot fix. When I register a user, the form works and the user is logged in. The logout also works, but when I login the user which has already registered, Laravel doesn't logs him in. Instead, it directs the user back to t...
GeorGios
0

votes
0

answer
6

Views

Laravel cronjob not working on bluehost shared hosting

I have set up laravel website on bluehost shared hosting. Here I want to use cronjob to get daily soccer match schedule with utc time. My cronjob command is as follows: /opt/cpanel/ea-php72/root/usr/bin/php /home1/kpabalco/public_html/bet/artisan schedule:run 1>> /dev/null 2>&1 If I run this command...
BaiMaoli
0

votes
0

answer
5

Views

How to write Laravel eloquent query inside model function?

Actually I don't know how to retrieve data from db using function and query inside model .Please help me what should i add inside model function. Here is controller public function checkAdmin(Request $request){ $data = array(); $data['email'] = $request->email; $data['password'] = $request->passwor...
Imran
1

votes
2

answer
77

Views

How to center Processing message in laravel-datatables with existing data?

In my laravel 5.7 application I use "yajra/laravel-datatables-oracle": "~8.0" library and reading this https://m.datatables.net/forums/discussion/25666/how-to-customize-the-processing-message I modified processing message with style : .dataTables_processing { margin-top: -80px !important; padding:...
mstdmstd
1

votes
2

answer
1.8k

Views

How to optimise handle of big data on laravel?

My task is: "To take transactions table, grouped row by transaction date and calculate statuses. This manipulations will be formed statistics, wich will be rendered on the page". This is my method of this statistics generation public static function getStatistics(Website $website = null) { if($websi...
Scrobot
1

votes
2

answer
14

Views

How to join 3 tables with Laravel's Eloquent relationships?

So, an order has a foreign_key offer_id. And an offer has a foreign_key item_id. An item may be in multiple offers. But every offer has one item. An offer may be in multiple orders. But every order has one offer. When I do this: $orders = Auth::user()->orders() ->with('offer') ->get(); I get this:...
padawanTony
0

votes
0

answer
14

Views

Multiple Domains w/ Single Laravel Install

Sort of consolidating a few questions that are old, unresolved, and kind of in keeping with my own problem. Routes file: echo url()->current() .""; echo request()->getHost(); Route::domain('pro.local')->group(function () { Route::get('/', function () { dd('HELLO'); }); }); Route::group(['domain' =>...
Josh Bruce
1

votes
2

answer
364

Views

How to get extra fields from pivot table - laravel

I have create a Pivot model and table for laravel and added extra field to the pivot model. But the extra field is not displaying when calling pivot data. I have a Customer model and Tag model. And a pivot called CustomerTag Created a User with tags and added extra fiend to pivot table using $user =...
noufalcep
1

votes
0

answer
10

Views

Laravel & Html DataTable with Export buttons not showing or displaying

Why my export buttons like PDF, EXCEL CSV not showing or displaying on my page? here is what my table looks like enter image description here here are my js links enter image description here EMPLOYEE NO. NAME DATE TIME IN TIME OUT TOTAL HOURS STATUS @foreach ($employeeSched as $setTime) {{ $setTim...
happy coding 101
1

votes
1

answer
850

Views

Laravel Pagination with get() function

This is the controller function. I need to set pagination for this. public function student_list(){ $students = Student::orderBy('first_name')->get(); $stu_na = "Test Page"; return view('student/student_list', compact('stu_na', 'students')); } After reading documentation I tried following ways. 1st...
Dreengreen
1

votes
1

answer
2.2k

Views

Laravel API TOKEN authentication not working

I am trying to authenticate user with api authentication token. But even after using correct token its saying unauthorized. I am using laravel auth and socialite for social authentication so my api.php route is like this Route::group(['middleware'=>'auth:api'], function(){ Route::get('hello','ApiTe...
user7747472
1

votes
1

answer
599

Views

How to use array for ->whereMonth Laravel?

Is it possible to use array as value for function DB: ->whereMonth($month); Like this: ->whereMonth([01, 02, 12]);
Karabah
1

votes
2

answer
312

Views

How can I solve case-sensitive where like statement on json data in Laravel eloquent?

I use Laravel 5.6 and mysql database. My Laravel eloquent query is like this: Order::where('information->owner', 'like', '%'.$receipt.'%')->paginate(5); Information field is a JSON type. {"owner": "Chelsea"} If $receipt is Chel, the query returns a result. But if $receipt is chel or CHEL, the resu...
Success Man
1

votes
1

answer
584

Views

Yajra DataTable addColumn

I use yajra datatable but i've get problem when I use the method "addColumn". the one I use that method is work properly, but the other doesn't this is my source code : ->addColumn('action', function($arrProduct){ return '  Proses'; }) ->addColumn('status', function($arrProduct){ if($arrProduct['st...
Almaida Jody
1

votes
2

answer
162

Views

Laravel: Cannot set locale in Mailable

I updated to Laravel 5.6 and I want to use the new locale method from a Mailable class. I created a mailable class with php artisan make:mail Test --markdown="emails.test" This is my blade file: @component('mail::message') @lang('list.test') @endcomponent If I send a mail $test = new \App\Mail\Test...
Adam
1

votes
2

answer
43

Views

Multiple orWhere() in whereHas() in Laravel 5

Contact Model class Contact extends Model { public function Account() { return $this->belongsTo('app\Account'); } } Account Model class Account extends Model { public function Contact() { return $this->hasMany('app\Contact'); } } I want to get query of all Contacts that have account_name = 'test' or...
paranoid
1

votes
2

answer
39

Views

laravel: Route [dashboard] not defined

when admin login then he redirects to dashboard page but by clicking on its main button(like home button) it shows error, i added this code: in it but it says: Route [dashboard] not defined this is my route: Route::get('/admin/dashboard','[email protected]'); any solution to resolve this...
programmer0001
1

votes
2

answer
52

Views

How to loop and compare multiple data passed from a single view Laravel

I have this function in my GlobalController: public function edit(Request $request, $id) { $isChanged = false; if (!$request) { $isChanged = true; } $user = User::find($id); $user->first_name = $request->first_name; $user->last_name = $request->last_name; $user->email = $request->email; $user->birth...
Justin F
6

votes
1

answer
37

Views

proengsoft/laravel-jsvalidation failed working with using harvesthq/chosen library?

In my laravel 5.7/ blade / jQuery v3.3.1 / Bootstrap v4.1.2 app I use https://github.com/proengsoft/laravel-jsvalidation library, with definition in my blade form {!! JsValidator::formRequest('App\Http\Requests\StorageSpaceRequest', '#form_storage_space_edit'); !!} where StorageSpaceRequest is file...
mstdmstd
0

votes
0

answer
9

Views

Laravel Sort hasMany relationship by Array values

I have this method in a Model called Category, that brings all products from certain Category. public function products() { return $this->hasMany(Product::class); } What I would like is put these products in order based on Array with IDs. I tried this but didn't work: public function products() { if...
Vinicius Cainelli
1

votes
0

answer
16

Views

Laravel LengthAwarePagination

I am working with laravel's LengthAwarePaginator Class. My problem is that I cannot use $users = DB::table('users')->paginate(15); or in other words,larvel's querybuilder or eloquent results. The reason is I have provided user with a frontend where they can create queries dynamically that can as si...
umair.ashfr
0

votes
0

answer
12

Views

group route middleware not being called

what I'm trying to do is group multiple prefixes with one middleware : Route::group(['middleware' => ['centralize']], function () { Route::group(['prefix' => \App\Utilities\Centralization::setLocale()], function () { Route::group(['prefix' => \App\Utilities\Centralization::setCountry()], function ()...
Abanoub
0

votes
0

answer
7

Views

How come I need to completely restart my server whenever changing Laravel settings?

Nowhere on the internet have I seen anyone have this issue, but I pretty much can't change or add any config/package/vendor without restarting my entire Linux server. Some simple examples: For Intervention image, I set the driver to Imagick in config/image, in the controller itself Image::configure...
MitchEff
0

votes
4

answer
44

Views

Why route() function does now works using laravel?

In my laravel package the route does not working it is showing following incorrect route in debugger Request URL: http://localhost:8000/%7B%7B%20route('contact')%20%7D%7D However my route is as following Route::group(['namespace' => 'ayazdev\Contact\Http\Controllers'], function(){ Route::get('conta...
Imran Abbas
0

votes
0

answer
26

Views

Array getting converted to stdClass on addition

I have two arrays which I want to add under certain conditions which is provided by for loop. But I get the error, "Object of class stdClass could not be converted to number." on the last line. $reld=DB::table('jp')->select('cp')->get()->toArray(); //dd($reld); for($i=19;$i float(170.6) } [1]=> obj...
Ken Graham
1

votes
2

answer
3.1k

Views

Laravel Image Default

My user uploads a profile picture which is stored in storage/profile_picture/user1.png. I use Filesystem and Storage classes to do so. To retrieve the image I use {!! Html::image(route('profile.thumbnail', $user->profilepic_filename), "Your Picture Here", ['class'=>'img-responsive']) !!} In my Contr...
karmendra
1

votes
2

answer
3.6k

Views

Laravel 5.1: Unable to display $errors->first in template

I have following html: Question @if ($errors->has('question')) {!! $errors->first('question') !!} @endif @if( $errors->has('question')) {{ $errors->first('question') }} @endif Answer My problem is that, only $errors->all() is working. But $errors->has('question'), $errors->first('question') not wor...
Simpanoz
1

votes
1

answer
129

Views

Cannot update in laravel

Hello I am new in Laravel and this is my first app I am getting error: Call to undefined method stdClass::save() This is my modal code named Song.php:
Yatin Khullar
1

votes
2

answer
251

Views

location of helper function in Laravel 5

I am using Laravel 5 and new in this Platform. I studied about URL:asset In the earlier version of PHP, we could find the helper function in Auto Load or config files. Do the helper function list exists somewhere in the Framework directory where if we want to change something in the helper function...
Pankaj
1

votes
1

answer
30

Views

using Bootstrap3 form in laravel5.1

I am trying to make a form using bootstrap3 in laravel5.1 so that I can get values from user and store it on the database and want to redirect the same page. here is the form part of my code -- ADD NEW ITEM Submit but this part action="{{url('fastshops/menu')}} is not working ! If I click on the sub...
Erfan Ahmed

View additional questions