AlexDemin

AlexDemin

Member Since 2 Years Ago

Yekaterinburg, Russia

Certified Laravel Developer at Demin.online

Experience Points 55,650
Experience Level 12

4,350 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 466
Lessons
Completed
Best Reply Awards 14
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

17 Aug
11 months ago

AlexDemin started a new conversation Any News About Laratalent.com?

Hey guys,

Did I miss any news about laratalent.com? Now it redirects to larajobs.com

11 Jul
1 year ago

AlexDemin left a reply on Handle Time And Memory Limits For Executing A Script

You can use ini_set('max_execution_time', 300); and ini_set('memory_limit', '8M'); in the script. You can also consider using Jobs to run during a Queue.

btw, there's a nice package for backups https://packagist.org/packages/spatie/laravel-backup

05 Jul
1 year ago

AlexDemin left a reply on Identify User Without Login

Let's suppose you have a $request->coupon_code and Eloquent relations (one to many) like User->coupons(), in this case, you can identify the user this way:

$user = User::whereHas('coupons', function ($query) {
    $query->where('coupon_code', 'like', request()->coupon_code);
})->firstOrFail();

AlexDemin left a reply on Create 2 Different Kinds Of Middleware Groups

As an option:

  1. check_all_of_them - that's a default behavior of middleware groups

  2. you can use Cache to store the intermediate state

04 Jul
1 year ago

AlexDemin left a reply on OrderBy For GroupBy Does Not Work?

@jamesjames Ok, your SQL query looks fine then.

Try to change mysql mode option 'strict' => false, in your config/database.php

AlexDemin left a reply on OrderBy For GroupBy Does Not Work?

Do you really have conversation_id column in this table? I don't see it in your original post.

AlexDemin left a reply on OrderBy For GroupBy Does Not Work?

Please replace ->get() with ->toSql(), then dd($messages) - what is the output?

03 Jul
1 year ago

AlexDemin left a reply on Route [add.answer.create_answer] Not Defined

Please list your routes:

php artisan route:list

AlexDemin left a reply on Why Pagination Laravel Ignores Requests

You may append to the query string of pagination links using the appends method. For example, to append sort=votes to each pagination link, you should make the following call to appends:

{{ $users->appends(['sort' => 'votes'])->links() }}

https://laravel.com/docs/5.6/pagination

AlexDemin left a reply on Database Query

Your query looks to be correct.

But you can also try to pass an array of conditions to the where function:

$has_favourites = favourites::where([
    ['student_id', $request->student_id],
    ['quiz_id', $request->quiz_id],
])->exists();

See https://laravel.com/docs/5.6/queries#where-clauses

Also, you can debug your query. Put this code before your query:

DB::listen(function ($query){
    dump($query->sql);
    dump($query->bindings);
    dump($query->time);
});
02 Jul
1 year ago

AlexDemin left a reply on Time Consuming Script

@stefr Sorry for a stupid question. Have you restarted a queue worker after changing the timeout param?

AlexDemin left a reply on Time Consuming Script

You could create a job class for this script. Then run a queue worker with a timeout specified:

php artisan queue:work --timeout=120

AlexDemin left a reply on How To Save One Form Data To Two Data Tables In Laravel 5.6

public function store(Request $request)
    {
        $this->validate($request,[
            'district' => 'required',
            'town' => 'required',
            'brand' => 'required',
            'model' => 'required',
            'year' => 'required',
            'optradio' => 'required',
            'milage' => 'required',
            'tramsmission' => 'required',
            'fuel' => 'required',
            'enginecap' => 'required',
            'data' => 'required',
            'price' => 'required',
            'telephone' => 'required',
            'email' => 'required',
            'name' => 'required',
            'filename' => 'required',
        ]);

        $vehicle = new Vehicle;
        $vehicle->district = $request->input('district');
        $vehicle->town = $request->input('town');
        $vehicle->brand = $request->input('brand');
        $vehicle->model = $request->input('model');
        $vehicle->year = $request->input('year');
        $vehicle->condition = $request->input('optradio');
        $vehicle->milage = $request->input('milage');
        $vehicle->transmission = $request->input('tramsmission');
        $vehicle->fuel_type = $request->input('fuel');
        $vehicle->engine_capacity = $request->input('enginecap');
        $vehicle->detail = $request->input('data');
        $vehicle->price = $request->input('price');
        $vehicle->telephone = $request->input('telephone');
        $vehicle->email = $request->input('email');
        $vehicle->name = $request->input('name');
    $vehicle->save();

    $car = new Car;
    $car->milage = $request->input('milage');
    $car->transmission = $request->input('tramsmission');
    $car->fuel_type = $request->input('fuel');
    $car->engine_capacity = $request->input('enginecap');
    $car->save();

    // redirect()->route(...)
}

AlexDemin left a reply on How To Save One Form Data To Two Data Tables In Laravel 5.6

@Msoft in the same method of your VehicleController

AlexDemin left a reply on How To Save One Form Data To Two Data Tables In Laravel 5.6

Why not to do just the following:

$car = new Car;
$car->milage = $request->input('milage');
$car->transmission = $request->input('tramsmission');
$car->fuel_type = $request->input('fuel');
$car->engine_capacity = $request->input('enginecap');
$car->save();

AlexDemin left a reply on Print True Or False Using Blade And Resources

You can use Attribute Casting on your model:

class bannersModel extends Model
{
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'activo' => 'boolean',
    ];
}
01 Jul
1 year ago

AlexDemin left a reply on Multiple Condition Laravel Join()

I'd recommend using advanced joins in this case:

Post::has('comments.votes')
        ->join('tafsir_ahbayan', function ($join) {
            $join->on('tafsir_ahbayan.surah_id', '=', 'quran.surah_id')
        ->orOn('tafsir_ahbayan.my_id', '=', 'quran.my_id');
        })
        ->get();

AlexDemin left a reply on Multiple Condition Laravel Join()

There are also Advanced Join Clauses:

DB::table('users')
        ->join('contacts', function ($join) {
            $join->on('users.id', '=', 'contacts.user_id')->orOn(...);
        })
        ->get();

or

DB::table('users')
        ->join('contacts', function ($join) {
            $join->on('users.id', '=', 'contacts.user_id')
                 ->where('contacts.user_id', '>', 5);
        })
        ->get();

AlexDemin left a reply on Multiple Condition Laravel Join()

Post::has('comments.votes')
    ->join('tafsir_ahbayan', 'tafsir_ahbayan.surah_id', '=', 'quran.surah_id')
    ->where(...another conditions...)
    ->get();
29 Jun
1 year ago

AlexDemin left a reply on Laravel Redirect Back To Post Route, I Get MethodNotAllowedHttpException

@baloch no problem, you can store variables in DB, session or cache.

In showPuchasedPacks method, you will be able to load these variables and transmit them to the desired view.

AlexDemin left a reply on Laravel Redirect Back To Post Route, I Get MethodNotAllowedHttpException

Why not add an intermediate get route to show the second form?

Route::get('/purchasePacks', '[email protected]');
Route::post('/confirmPuchasedPacks','[email protected]');
Route::get('/confirmPuchasedPacks','[email protected]');
Route::post('/storeOrder','[email protected]');

AlexDemin left a reply on Laravel Redirect Back To Post Route, I Get MethodNotAllowedHttpException

Please list your routes and the controller method with the redirect statement.

21 May
1 year ago

AlexDemin left a reply on Slow Query Where Has With Big Data

Article Tag

I don't see constraints here...

AlexDemin left a reply on Slow Query Where Has With Big Data

Please list your migrations: articles, tags, article_tag

20 May
1 year ago

AlexDemin left a reply on Undefined Property: Illuminate\Pagination\LengthAwarePaginator::Is There A Way To Replace It?

I tried but failed. Can you give me the code sample?

public function index()
    {
        $schools_lists = SchoolsList::where('user_id', Auth::user()->id)->latest()->paginate(25);
        return view('Admin.submit-information.all', compact('schools_lists '));
    }

AlexDemin left a reply on Undefined Property: Illuminate\Pagination\LengthAwarePaginator::Is There A Way To Replace It?

Here is your problem:

if(Auth::user()->id == $schools_lists->user_id){

$schools_lists is a collection of records, there is no user_id attribute.

Add where clause to your query to filter records by user_id.

AlexDemin left a reply on Login Infinite Redirect

I guess this route xxx.xxx.xxx.xxx/admin/public/login is also protected with middleware(['auth']) - so you get infinite redirect...

19 May
1 year ago

AlexDemin left a reply on Auth:make Command Default Login Registration Page

I guess you need to run migrations:

php artisan migrate

Take a look at the documentation https://laravel.com/docs/5.6/authentication

Want to get started fast? Just run php artisan make:auth and  php artisan migrate in a fresh Laravel application. Then, navigate your browser to http://your-app.test/register or any other URL that is assigned to your application. These two commands will take care of scaffolding your entire authentication system!
14 May
1 year ago
12 May
1 year ago

AlexDemin left a reply on Login And Register Works Locally, But Doesn't Work After It Deployed To The Web

Login and Register is nothing to do with Mail

That's not quite correct. There is a password reminder logic, that engages Mail.

So you just need to provide correct mail credentials. Or set your mail driver to log.

AlexDemin left a reply on Best Practice For Storing Lots Of Fields?

The error is about post_title not job_title.

Your for has an empty value for post_title, but you have not provided any default value (or ->nullable()) in your migration. So you get an error here...

AlexDemin left a reply on Call To Undefined Method League\OAuth2\Server\AuthorizationServer::setEncryptionKey()

Also, if I correctly understood you, you have this issue only on your production server.

To avoid such situations with a difference between dev/prod server, it's recommended to include composer.lock file to your git repo.

So when you run on your production

git clone ...
composer install

you will get absolutely the same configuration as on your dev server.

AlexDemin left a reply on How I Can Do Dynamic Banner

You can create exactly the same image as you provided using this library and job scheduling. You will need to generate this image every X minutes.

  1. Create a job to generate this image https://laravel.com/docs/5.6/queues#creating-jobs
php artisan make:job GenerateImage
  1. In your job, you will need

First - check the status of that server (online/offline)

Second - generate the image and save it

  • Need multiline text? Use several calls of $img->text() with appropriate params
  • Need to paste online/offline status? Paste a green/red rectangle http://image.intervention.io/api/rectangle and then paste the text inside

It's like a Photoshop, you draw elements one-by-one. You have no CSS here, it's not an HTML banner.

AlexDemin left a reply on How I Can Do Dynamic Banner

So you have provided a link to the documentation... Why not spend an hour studying it?

Take a look at examples in the bottom of each page: http://image.intervention.io/api/text http://image.intervention.io/api/insert

AlexDemin left a reply on How To Use Laravel Policies Via Middleware In 5.6?

What about linking custom method names in controller and policy files?

Just create the corresponding method in your policy. You only need to link your policy to your model in AuthServiceProvider.

AlexDemin left a reply on How To Use Laravel Policies Via Middleware In 5.6?

Add your policy to your AuthServiceProvider:

    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Post' => 'App\Policies\PostPolicy',
    ];

That's enough, you don't need to change routes in this case.

Take a look at the documentation: https://laravel.com/docs/5.6/authorization#registering-policies

10 May
1 year ago

AlexDemin left a reply on MethodNotAllowedHttpException On File Upload

  • run: "php artisan:list" preferably on your production server.
  • indicate the route (POST method) that corresponds to this form.
  • set that named route as your form action:
<form role="form" method="POST" action="{{ route('name.of.your.route') }}" enctype="multipart/form-data"> 

AlexDemin left a reply on MethodNotAllowedHttpException On File Upload

MethodNotAllowedHttpException is usually about your routes file...

08 May
1 year ago

AlexDemin left a reply on Search Method Which Queries By Nested Relationship Fields

Could you list your investor() relation from the User model?

AlexDemin left a reply on Search Method Which Queries By Nested Relationship Fields

  1. Did you get any errors before changing ->paginate(15) to ->toSql()? Does that query work?

  2. (only after that) ->get()->toSql() would be more correct, I guess.

AlexDemin left a reply on Array Data Not Storing In Database

The problem is here '$request->scores[$i]'

AlexDemin left a reply on Search Method Which Queries By Nested Relationship Fields

  1. I've also fixed your duplicate returns. Could you please run that exact query from my previous message. And list errors if any?

  2. Then please dump your sql query:

$investors = User::with('investor', 'investments')
    ->...
    ->toSql(); // instead of paginate(15);

dd($investors);

AlexDemin left a reply on Search Method Which Queries By Nested Relationship Fields

also my model (User, Investor) and database names (users, investors) are correct.

In this case, you need to change investor.phone to investors.phone in your query (the same for other columns).

$investors = User::with('investor', 'investments')
    ->join('investors', 'users.id', '=', 'investors.user_id')
    ->where('users.type', 'investor')
    ->when($request->has('firstname'), function($query) use ($request){
        return $query->where('investors.firstname', 'LIKE', "%{$request->firstname}%");
        return $query->where('investors.firstname', 'LIKE', "%$request->firstname%");
    })      
    ->when($request->has('lastname'), function($query) use ($request){
        return $query->where('investors.lastname', 'LIKE', "%{$request->lastname}%");
        return $query->where('investors.lastname', 'LIKE', "%$request->lastname%");
    })              
    ->when($request->has('email'), function($query) use ($request){
        return $query->where('users.email', 'LIKE', "%{$request->email}%");
        return $query->where('users.email', 'LIKE', "%$request->email%");
    })                  
    ->when($request->has('phone'), function($query) use ($request){
        return $query->where('investors.phone', 'LIKE', "%{$request->phone}%");
        return $query->where('investors.phone', 'LIKE', "%$request->phone%");
    })  
    ->when($request->has('inquiries_all'), function($query) use ($request){
        return $query->where('investors.inquiries_all', '<=', $request->inquiries_all);
    })  
    ->when($request->has('inquiries_current_month'), function($query) use ($request){
        return $query->where('investors.inquiries_current_month', '<=', $request->inquiries_current_month);
    })  
    ->paginate(15);

AlexDemin left a reply on Search Method Which Queries By Nested Relationship Fields

Try to join tables https://laravel.com/docs/5.6/queries#joins

investors = User::with('investor', 'investments')
    ->join('investors', 'users.id', '=', 'investors.user_id')
    ->where('users.type', 'investor')
    ->...