agilasadi

agilasadi

Member Since 2 Years Ago

Azerbaijan, Lankaran

Software Engneer at Raplet

Experience Points 6,430
Experience Level 2

3,570 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 52
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

01 Jun
2 weeks ago

agilasadi left a reply on It Seems Like Laravel Boot Trait Doesn't Work

Here is what I ended up doing, works perfectly well


    public static function boot()
    {
        self::created(
            function($model)
            {
                Contribution::create([
                    'contributing_id' => $model->id,
                    'contributing_type' => $model->table
                ]);
            }
        );
    }

agilasadi left a reply on It Seems Like Laravel Boot Trait Doesn't Work

Here is the thing, dd() works inside the trait, but it does not work inside the static::creating

agilasadi left a reply on It Seems Like Laravel Boot Trait Doesn't Work

@TALINON - No, I do not have boot in my model

agilasadi left a reply on It Seems Like Laravel Boot Trait Doesn't Work

@SNAPEY - If it has the id or not, just to make sure creating the record is successful, but the code doesn't reach to that point, creating does not get triggered

agilasadi left a reply on It Seems Like Laravel Boot Trait Doesn't Work

@SNAPEY - It's quite the same as mine, but for some reason, it doesn't work. By the way, I think this method feels a lot cleaner

agilasadi left a reply on It Seems Like Laravel Boot Trait Doesn't Work

@JOHNBRAUN - Nothing it ignores the event entirely, but when I put dd before the event, it shows up when the page is loading

agilasadi started a new conversation It Seems Like Laravel Boot Trait Doesn't Work

Recently I'm having problems with using traits, I created some before and it seemed to work, but now I created another one to take action on a creating event, here it is


trait Contributes
{

public static function bootContributes()
{
    static::creating(function ($model) {
        if (!$model->getKey())
        {
            Contribution::create([
                'contributing_id' => $model->id,
                'contributing_type' => $model->class_table,
            ]);
        }
    });
}

}

and I included it in multiple models like use Contributes; I think there is something I don't know about it.

31 May
2 weeks ago

agilasadi started a new conversation Laravel Nova Access Restriction Vie Gate Does Not Work

I tried to restrict access to Nova depending on user role. Although It seems like I did everything according to the documentation, Nova seems to ignore it.

    protected function gate()
    {
        Gate::define('viewNova', function ($user) {
            return in_array($user->role_id, [
                '1'
            ]);
        });
    }
16 May
1 month ago

agilasadi left a reply on Nova Actionable_id Cannot Be Null

@DEVFREY - Shoot, that is it. :D Thanks for your assistance <3

agilasadi left a reply on Nova Actionable_id Cannot Be Null

@DEVFREY - I didn't try that be clearly, generating guid with a trait was the problem. It worked just by disabling the trait which I'm absolutely not happy with :/

agilasadi left a reply on Nova Actionable_id Cannot Be Null

So here is the trait I added for the Model:

trait UsesUuid
{
    protected static function bootUsesUuid()
    {
        static::creating(function ($model) {
            if (!$model->getKey())
            {
                $model->guid = (string)Str::uuid();
            }
        });
    }

    public function getIncrementing()
    {
        return false;
    }

    public function getKeyType()
    {
        return 'string';
    }
}

it seems like disabling trait lets this work.

How else I can generate the guid field?

agilasadi left a reply on Nova Actionable_id Cannot Be Null

@devfrey here is the fields for the Site resource:


            ID::make()
                ->hideWhenCreating()
                ->hideWhenUpdating(),

            Text::make('Guid')
                ->withMeta(['value' => (string)Str::uuid()]),

            Text::make('Site Title')
                ->creationRules('required'),

            Text::make('Site Contents')
                ->creationRules('required'),

            Number::make('Record Priority'),

            Select::make('Record State')->options([
                '1' => 'Active',
                '0' => 'Disabled',
                '2' => 'Draft',
            ])->displayUsingLabels(),

            BelongsTo::make('Created By', 'creator', 'App\Nova\User')
                ->creationRules('required'),

            BelongsTo::make('Updated By', 'updater', 'App\Nova\User')
                ->creationRules('nullable'),

            HasMany::make('Sites', 'roles', 'App\Nova\RoleSites')

I can share model as well if you want to see it

agilasadi left a reply on Nova Actionable_id Cannot Be Null

@munazzil As @devfrey mentioned, it's created_by which corresponds to the creator of the record

agilasadi left a reply on Nova Actionable_id Cannot Be Null

@devfrey As far as I remember I didn't do anything like that

agilasadi started a new conversation Nova Actionable_id Cannot Be Null

Apparently none of my create functions is working, the all keep throwing:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'actionable_id' cannot be null (SQL: insert into `action_events` (`batch_id`, `user_id`, `name`, `actionable_type`, `actionable_id`, `target_type`, `target_id`, `model_type`, `model_id`, `fields`, `status`, `exception`, `updated_at`, `created_at`) values (8db303d9-39ca-4858-8d59-30ec1cd51cb7, 1, Create, App\Models\Site, ?, App\Models\Site, ?, App\Models\Site, ?, , finished, , 2019-05-16 09:47:12, 2019-05-16 09:47:12))

Basically, it says 'actionable_id' can not be 'null'`.

Here is a sample of my table:


            $table->bigIncrements('id');
            $table->string('guid')->unique();

            $table->string('site_title');

            $table->string('site_contents')->nullable();

            $table->integer('record_priority')->default('0');
            $table->integer('record_state')->default('1');
            $table->string('created_by');
            $table->string('updated_by')->nullable();

            $table->softDeletes();
            $table->timestamps();

I generate guid with trait, but for the sake of making this work, I even tried it manually, no luck.

It works just fine when I create it with tinker.

13 May
1 month ago

agilasadi left a reply on Fields In Nova For Inserting Data With Child Table

I see thanks for your help <3

agilasadi left a reply on Fields In Nova For Inserting Data With Child Table

Should I also have a model and Nova Resource for the child table?

agilasadi left a reply on Fields In Nova For Inserting Data With Child Table

How am I going to have multiple fields for inserting that role translations?

agilasadi started a new conversation Fields In Nova For Inserting Data With Child Table

I have quite a little experience with the capabilities of Nova, but recently I started working on a multi-lingual application with Nova. Here is the point where I got stuck.

My table structure is somewhat like below:


        Schema::create('roles', function (Blueprint $table) {
            $table->bigIncrements('auto_id');
            $table->string('id');

            $table->timestamps();
            $table->softDeletes();
        });

        Schema::create('role_translation', function (Blueprint $table) {
            $table->string('role_id');
            $table->string('translation_id');

            $table->string('role_name');
            $table->string('role_description')->nullable();

            $table->string('created_by');
            $table->string('updated_by')->nullable();

            $table->timestamps();
            $table->softDeletes();
        });

Now when I insert into roles I also need to insert into role_translations I don't know how to provide fields for Nova to give me the desired interface.

agilasadi left a reply on Hasone RelationsShip (Create View) - Laravel Nova

I don't feel comfortable with this solution, to be honest. But thanks for sharing.

04 May
1 month ago

agilasadi left a reply on Weird Behaviour On Paginating With Join And `having` Clause

Just to let you know, the code you have given is kind of not readable :/

11 Apr
2 months ago

agilasadi left a reply on PhpDoc In Laravel

@MSTNORRIS - But ApiGen is used for generating API documentation, like swagger. phpDocumentor is used for generating code documentation out of code blocks

27 Mar
2 months ago

agilasadi left a reply on Installing Nova 2.0 On Laravel 5.8 Is Throwing Errors

Ok that actually did it, my bad. thanks for helping me out

agilasadi left a reply on Installing Nova 2.0 On Laravel 5.8 Is Throwing Errors

You mean bcmath right? If so, I;m able to see it

agilasadi started a new conversation Installing Nova 2.0 On Laravel 5.8 Is Throwing Errors

I followed the guide from Nova documentation. after adding the required lines into composer.json I tried to run composer update and this is what I get:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/nova 2.0.x-dev requires moontoast/math ^1.1 -> satisfiable by moontoast/math[1.1.0, 1.1.1, 1.1.2].
    - laravel/nova dev-master requires moontoast/math ^1.1 -> satisfiable by moontoast/math[1.1.0, 1.1.1, 1.1.2].
    - moontoast/math 1.1.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
    - moontoast/math 1.1.1 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
    - moontoast/math 1.1.0 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
    - Installation request for laravel/nova * -> satisfiable by laravel/nova[2.0.x-dev, dev-master].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.2/cli/php.ini
    - /etc/php/7.2/cli/conf.d/10-mysqlnd.ini
    - /etc/php/7.2/cli/conf.d/10-opcache.ini
    - /etc/php/7.2/cli/conf.d/10-pdo.ini
    - /etc/php/7.2/cli/conf.d/15-xml.ini
    - /etc/php/7.2/cli/conf.d/20-bz2.ini
    - /etc/php/7.2/cli/conf.d/20-calendar.ini
    - /etc/php/7.2/cli/conf.d/20-ctype.ini
    - /etc/php/7.2/cli/conf.d/20-curl.ini
    - /etc/php/7.2/cli/conf.d/20-dom.ini
    - /etc/php/7.2/cli/conf.d/20-exif.ini
    - /etc/php/7.2/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.2/cli/conf.d/20-ftp.ini
    - /etc/php/7.2/cli/conf.d/20-gd.ini
    - /etc/php/7.2/cli/conf.d/20-gettext.ini
    - /etc/php/7.2/cli/conf.d/20-iconv.ini
    - /etc/php/7.2/cli/conf.d/20-json.ini
    - /etc/php/7.2/cli/conf.d/20-mbstring.ini
    - /etc/php/7.2/cli/conf.d/20-mysqli.ini
    - /etc/php/7.2/cli/conf.d/20-pdo_mysql.ini
    - /etc/php/7.2/cli/conf.d/20-phar.ini
    - /etc/php/7.2/cli/conf.d/20-posix.ini
    - /etc/php/7.2/cli/conf.d/20-readline.ini
    - /etc/php/7.2/cli/conf.d/20-shmop.ini
    - /etc/php/7.2/cli/conf.d/20-simplexml.ini
    - /etc/php/7.2/cli/conf.d/20-sockets.ini
    - /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.2/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.2/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.2/cli/conf.d/20-tokenizer.ini
    - /etc/php/7.2/cli/conf.d/20-wddx.ini
    - /etc/php/7.2/cli/conf.d/20-xmlreader.ini
    - /etc/php/7.2/cli/conf.d/20-xmlwriter.ini
    - /etc/php/7.2/cli/conf.d/20-xsl.ini
    - /etc/php/7.2/cli/conf.d/20-zip.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

any help is appreciated in advance.

04 Mar
3 months ago

agilasadi left a reply on Getting Error In Container.php Line 779: Class Request Does Not Exist

We can help you better if you share some of the code, it's hard to guess. Other than that as @bobbybouwmann mentioned, you might have defined Request class wrongly

agilasadi left a reply on Nova: How Do I Check Whether The User Is Inside The Admin Panel?

I don't have much experience with Nova but if you have multiple guards you can check that by @if(Auth::guard('type')->check())

23 Feb
3 months ago

agilasadi started a new conversation Carbon Throwing Errors In Lamp Server

Laravel is throwing Class Carbon not found, I created the application in local environment and it's working, but when I deployed it to digitalocean server, it doesn't seem to work. here is the code:

{{ \Carbon\Carbon::parse($entity['start_date'])->format('d') }}

And we also tried:

{{ Carbon::parse($entity['start_date'])->format('d') }}

And here is the error it throws:

Class 'Carbon' not found (View: /var/www/html/resources/views/common/components/single_slider_event.blade.php) (View:

And the alies is set up correctly:

'aliases' => [
      'Carbon' => Carbon\Carbon::class,
],

Any help is appreciated in advance.

22 Feb
3 months ago

agilasadi left a reply on How To Get None Related Objects Of Many To Many Relationship

@BOBBYBOUWMANN - Yes, I would like to join, that is the best option that comes to my mind. I just can't imagine it.

agilasadi started a new conversation How To Get None Related Objects Of Many To Many Relationship

I have users and news table and then a middle table called news_user, the middle table determines which news has been seen by the user. I can easily get objects that have been seen but, but now I need to show the user objects that have not been seen.

I did a workaround with putting all the seen news id in an array and look for news where id differs from the array. but I don't consider it as the healthiest solution.

This is what I did:

$seenNewses = DB::table('news_user')->where('user_id', Auth::id())
->pluck('news_id')->toArray();
$notSeenNewses = News::whereNotIn('id', $seenKeepers)
->orderBy('id', 'asc')->first();

Is there a way I can do this with a single query?

P.S: I have seen similar questions but they got me a little confused. Any answer is appreciated.

03 Jan
5 months ago

agilasadi left a reply on Setting Up Spatie Image Optimization Tools On Windows

@D9705996 - Thanks a lot, I'm gonna try that right now, and if there are no any other recommendations until I get that working your way, I will sign this answer as the best answer <3

agilasadi left a reply on Setting Up Spatie Image Optimization Tools On Windows

Ues you are right that is the package I use, I actually tried to link that but couldn't do. I'm trying all the tools. VirtualBox option has been recommended to me a few times but I don't see it as a sold solution, because there are some other people working on the project, I don't know how this is gonna affect them due to my inexperience. Can't I manually set the tools up?

agilasadi started a new conversation Setting Up Spatie Image Optimization Tools On Windows

I've asked a similar question some time ago but didn't get any response. Did a lot of digging and asked the question in many chat groups in, it seems like nobody ever tried using Spatie on Windows home. The issue is that I can easily set up and start using the package, but there is almost no way to set up those tools spatie uses. I considered using Docker, but I can not install Docker on Windows Home. So really stuck with tools, it throws no errors but doesn't really optimize images.

05 Dec
6 months ago

agilasadi started a new conversation Why Do I Get Random "SSL Certificate Problem" Error

I'm aware that the similar questions were asked but mine is differentiating and I could not find a matching answer.

The problem occurs when I'm trying to register users with social media options, or when I'm trying to do request to google for reCaptcha. In case of reCaptcha, it's acceptable since I due to a cURL request which can lead to an issue related with certification, But I could not find the reason why I get the error when I'm trying to register the user with Google or Facebook.

I tried to placing cacret.pem into PHP folder and linking it in the php.ini it was working for about 3 months and suddenly decided to not work. In this case, I'm not sure which part of the code I should share because I don't know what causes the error since I do not call Guzzle in any stage of social media registration. But since I use socialite, it might be using guzzle for doing requests.

HERE IS MY GOOGLE REGISTRATION:

try {

$googleUser = Socialite::driver('google')->user();
$existUser = User::where('email',$googleUser->email)->first();

if($existUser) {
    Auth::loginUsingId($existUser->id);
}
else {

    $user = new User;

    $user->name = $googleUser->name;
    $user->email = $googleUser->email;
    $user->password = str_random(40);
    $user->save();

    $account = new SocialMediaAccount([
        'provider_user_id' =>  $googleUser->id,
        'provider' => 'google'
    ]);

    $account->user()->associate($user);
    $account->save();

    Auth::loginUsingId($user->id);
}

return redirect()->to('/home');
}
catch (Exception $e) {
        return 'error';
}

ENTIRE ERROR: "cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

06 Jul
11 months ago

agilasadi left a reply on Stopping Multiple Form Submission.

I'm dealing with the same issue. But the real issue is that, this can happen even with the get requests, you need to somehow disable user from sending same request multiple times in a short duration. you eather should get requests delied in orther to see if the user is going to send it multiple times or you should disable request button for a few seconds once used. but this solution wont help much

16 Jun
1 year ago

agilasadi started a new conversation Implementing Summernote And Uploading Image Issue

I'm trying to upload images withing the summernote, the problem is, when i return the filename after upload, i can not insert it in the editor, like it does return the name, i can output it in console but does not add up to the rest of path. here is the code

    $('#texteditor').summernote({
        height: 400,
        callbacks: {
            onImageUpload: function(file, editor, welEditable) {
                uploadImage(file[0], editor, welEditable);
            }
        }
    });

    function uploadImage(file, editor, welEditable) {
        var data = new FormData();
        data.append("file", file);
        data.append("_token", globalToken);
        data.append("article_token", article_token);
        $.ajax({
            type: "POST",
            url: uploadArticleImages,
            data: data,
            success: function(url) {
                console.log(url);
                var image = $('<img>').attr('src','http://localhost/appName/public/storage/article_resim/' + url);
                $('#texteditor').summernote("insertNode", image[0]);
                console.log("success");



            },
            cache: false,
            contentType: false,
            processData: false,
            error: function(data) {
                console.log(data);
            }
        });
    }

the url i receive for the image is

  http://localhost/appName/public/storage/article_resim/[object%20Object]

but it shows me the actuall filename in the console with "url"

16 Feb
1 year ago

agilasadi left a reply on Composer View Is Not Loading Variable Into View

Yeah I did, But I still feel like it is something related with calling the composer. It's like the composer does not get triggered

15 Feb
1 year ago

agilasadi left a reply on Composer View Is Not Loading Variable Into View

@rin4ik thanks for advic, I tried it, noting changes

agilasadi left a reply on Composer View Is Not Loading Variable Into View

I updated it but some part are still not looking as formated, how do I do that ?

agilasadi started a new conversation Composer View Is Not Loading Variable Into View

I have a composer which is called EvenComposer inside that composer I have a function compose in there I try to return a variable $evens

class EvenComposer{ public function compose(View $view){ $evens = Even::all()->paginate(10); $view->with('evens', $evens); } }

And than a Provider which is called EvenComposerProvider is supposed to to call to that composer and load the data into the include view includes.aklinkoses with the code below:

public function register(){ $this->composeEven(); }

public function composeEven(){ view()->composer('layouts.aklinkosesi', 'App\Http\Composers\EvenComposer'); }

I also doublechecked or maybe more, if I Included it inside app.php

and I have the line in there App\Providers\EvenComposerProvider::class,.

Inside the view I have this code:

@foreach($evens as $even)

{{$even->content}}

@endforeach

pretty basic but yet gives the error: Undefined variable: evens

By the way, I have 3 other comopser views which work pretty normal so far. I might miss anything at all, haven't worked with composers for a while. If I didn't mention something than I probably missed it.

11 Feb
1 year ago

agilasadi left a reply on How To Get Posts Of Followed Users

It works like magic

agilasadi left a reply on How To Get Posts Of Followed Users

I want to see 10 posts in my news feed, It's like basically getting last 10 posts from database but only the ones made by the users I follow.

agilasadi started a new conversation How To Get Posts Of Followed Users

I'm trying to make news feed page, but in this page I need to output posts ordered by date and also they must belong to the user, which authed user follows. I tried a few things and than realised that I have the wrong logic. so in user model I have:

function followers()
{
    return $this->belongsToMany('App\User', 'followers', 'user_id', 'follower_id');
}

function follows()
{
    return $this->belongsToMany('App\User', 'followers', 'follower_id', 'user_id');
}

function articles(){
   return $this->hasMany('App\Article');
}

and than in article I have the relationships:

public function user()
{
    return $this->belongsTo('App\User');
}

I don't know if I can simplly get all articles and than output the ones the user follows. Any help would be usefull

30 Jan
1 year ago

agilasadi left a reply on I'm Trying To Send Mails When A User Signs Up. And Getting Connection Error.

Yeah that is what I have in my .env but when I ping smtp.mailtrap.io the request times out

agilasadi started a new conversation I'm Trying To Send Mails When A User Signs Up. And Getting Connection Error.

I use event listener for that and to try my mailing I use mailtrap, but I get an error that I don't know what excacly cousing it. here is what it looks like:

Connection could not be established with host smtp.mailtrap.io [php_network_getaddresses: getaddrinfo failed: A non-recoverable error occurred during a database lookup. #0]

Btw I defined all the infromation required in .env file

15 Jan
1 year ago

agilasadi left a reply on Get All Tag Models With Their Count In A ManyToMany Relationship In Laravel 5

Soyhuce I don't know what excetly you mean by Tag class? is it the tag model or what

26 Dec
1 year ago

agilasadi left a reply on How To Get Data From A Table Which Does Not Have Relationship With The Other One.

@xmarks I didn't wanted to have so many thing stored inside user table, I use it only for authetication and everything else will be inside userprofile