Category : php

how to make the encryption shorter in characters? Crypt::encrypt($event->id)) Result: http://myurl/id/eyJpdiI6Im5ub0hyaWJwVE1iendYbHNaSzJsSXc9PSIsInZhbHVlIjoiVHhpNmF4b3NlQjk2NFluRXhCOFZuQT09IiwibWFjIjoiZDkxNzk2OTlmZGRmZWJjYjFlNjExYjcyNWU4Y2Y4NWYwMjYxMTkxN2ZmNzU3NGM4Nzg0OWJkNjk1NmExNjVkZiIsInRhZyI6IiJ9 generates a very large link, I need to shorten it, is it possible? Sourc..

Read more

$validator = Validator::make($request->all(), [ ’email’ => ‘required|min:9|max:50|email’, ‘password’ => ‘required|min:8|max:255|password’ ]); if ($validator->fails()) { echo "Failed! Sorry :("; Session::flash(‘error’, $validator->messages()->first()); //return Redirect::back()->withErrors($validator); } else {… But if I write ‘password’ => ‘required|min:8|max:255’ the validation is passed, but when I write ‘password’ => ‘required|min:8|max:255|password’ it doesn’t pass and the result is "Failed! Sorry :(". I mean ..

Read more

I installed Laravel Passport and migrated the new tables just fine in my database. But when I try to run migrations for the testing database, ie. artisan migrate –database=testing I get: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘oauth_auth_codes’ already exists The only table that exists in the testing database is the migrations ..

Read more

In my laravel based application, when updating user accounts I’m trying to validate the birthday field. I have the following in my controller’s update method ‘date_of_birth’=>[‘required’,’date’, ‘date_format:Y-m-d’, function ($attribute, $value, $fail) { $age=Carbon::createFromFormat(‘Y-m-d’, $value)->diff(Carbon::now())->y; if($age<18||$age>70){ $fail(‘Âge invalide. l’âge devrait être 18-70’); } },] So the date format has to be Y-m-d and the age range ..

Read more

Inside a controller in Laravel I have this: public function index() { $users = User::orderBy(‘name’, ‘asc’)->paginate(13); $users2 = User::all(); return view(‘contatos.index’)->with(‘users’, $users); return view(‘auth.register’)->with(‘users’, $users2); } I know isn’t right, it’s just to demonstrate my logic. Is there a way to unite these two returns in a single return? Or even a much shorter form ..

Read more

I’ve created a simple laravel queue, a controller with a method which dispatches jobs into the queue, and a job for handling logic. My plan is to have multiple queue workers using Supervisor config. And it works fine. Supervisor config: /etc/supervisor/conf.d/worker-node.conf [program:laravel-worker] … autostart=true autorestart=true stopasgroup=true killasgroup=true user=admin numprocs=8 //8 concurrent workers … Problem is ..

Read more

I am using SQL server as database to connect from our Laravel project, and need the following connection properties to be set before all eloquent queries and raw Laravel queries: SET NOCOUNT ON; SET ANSI_NULLS ON; SET ANSI_PADDING ON; SET ANSI_WARNINGS ON; SET ARITHABORT ON; SET CONCAT_NULL_YIELDS_NULL ON; SET NUMERIC_ROUNDABORT OFF; SET QUOTED_IDENTIFIER ON; What ..

Read more

In my laravel based application, when creating new user accounts I’m trying to validate the birthday field. I have the following in my controller’s store method ‘date_of_birth’=>[‘required’,’date_format:m/d/Y’,function ($attribute, $value, $fail) { $age=Carbon::parse($value)->diff(Carbon::now())->y; if($age<18||$age>70){ $fail(‘Âge invalide. l’âge devrait être 18-70’); } },] So the date format has to be m/d/Y and the age range has to ..

Read more

I am using withCount() to count the number of articles in a category, everything works well. The question is how to count and display the number of articles for All categories? Controller $categories = BlogCategory::withCount(‘articles’)->get(); blade.php <div class="blog-filter"> <div class="blog-filter__item active" data-filter="all">All</div> @foreach($categories as $category) <div class="blog-filter__item" data-filter=".category_{{$category->id}}" value="{{ $category->title }} ({{ $category->articles_count }})">{{ $category->title ..

Read more

I have comment List API with Pagination in laravel and I want a comment replay Array with every comment but only the last 3 comment replay. public function CommentReplay(){ return $this->hasMany(‘AppPostCommentReplies’,’comment_id’,’id’)->orderBy(‘id’,’DESC’); } And Query I have use PostComments::select(‘post_comments.*’)->with([‘users’,’CommentReplay’=> function ($query) { $query->select(‘post_comment_replies.*’) ->orderBy(‘id’,’DESC’)->take(3); }])->orderBy(‘id’,’DESC’)->paginate(10); In this, I have been getting only the last 3 comments ..

Read more

I have this in view. It is able to upload alright but it won’t show. Is there anything more I should add? <div class="col-md-4"> <img class="img img-fluid img-thumbnail" src="/storage/profile_images/{{$profile->profile_image}}"/> </div> here is my show.blade.php file <div class="col-md-4"> <img class="img img-fluid img-thumbnail" src="/storage/profile_images/{{$profile->profile_image}}"/></div> Here is the player.blade.php file: @if(count($players) > 0) <?php $index = 0; ?> ..

Read more

I have installed Laravel project on Xampp folder and it uses php.ini for phpMyAdmin with this path – C:xamppphpphp.ini. But when I would like to create the facebook login, I have to put cacert.pem and write the absolute path in php.ini file outside Xampp folder, which is C:phpphp.ini. If I use php.ini in Xampp folder, ..

Read more

so this is my route Route::group([‘prefix’ => ‘{locale}’],function(){ Route::get(‘/’,’[email protected]′)->name(‘post’)->middleware(‘setLocale’);}); for example, if I chose es in lang or any other language I want to go to Route::group([‘prefix’ => ‘{locale}’],function(){ Route::get(‘/’,’[email protected]′)->name(‘post’)->middleware(‘setLocale’);}); **so I can fetch data from another JSON file with another language ** Sourc..

Read more