abdulaziz

abdulaziz

Member Since 2 Years Ago

Tajikistan Dushanbe

Experience Points 2,640
Experience Level 1

2,360 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 5
Lessons
Completed
Best Reply Awards 2
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.

23 Mar
5 months ago

abdulaziz left a reply on How To Remove Item From Cart Through Session Laravel 5.6?

// Get id of product
$id = $request->product;

// Get the product array
$cart = Session::get('cart');

// Unset the first index (or provide an index)
unset($cart->item[$id]); 

// Overwrite the product session
Session::put('cart', $cart);
14 Mar
6 months ago

abdulaziz started a new conversation How Development Process Works After Production?

Two questions:

  • I would like to know how do developers works after the project was pushed to production. Is somehow Github project is connected to hosting and whenever there is a new version on master branch it will be reflected on the hosting automatically?
  • Which hosting is more suitable for Laravel/Lumen rather than Forge (It is too expensive for me)?

Thanks in advance! Laracasts community is the best!

23 Jan
7 months ago

abdulaziz left a reply on Load Authenticated User For All/some Controllers

@sergiu17 @vilfago Thank you both! Don't know which question to mark as the correct one :D

abdulaziz started a new conversation Load Authenticated User For All/some Controllers

I have a two small questions:

  1. When I make Auth::User()does it make a query request?
  2. My User model has a lot of relationships. I load them like this:
Auth::User()->load('position','activities','department', ...);

but don't want to do it in each Controller. How can I load it once and use in all Controllers?

Thank you!

abdulaziz left a reply on Views Based On User Role

So why dont you mark Mr @snapey 's answer as a correct one

21 Jan
7 months ago

abdulaziz left a reply on Restful API

I was wondering if it is possible to make something like this in Laravel. If yes, how the structure would look like

alt text

20 Jan
7 months ago

abdulaziz started a new conversation Restful API

Hope you all doing good! I would like to make Restful API but I wonder how it must be used in the same project ? Do I make two types of Controller one will be for Restful API and another for returning views with jsons? What is the right way to do it? Thank you!

10 Dec
9 months ago

abdulaziz started a new conversation Fresh Project Weights Too Much?!

My fresh installation of Laravel weights 33.3 mb. When I run npm install, npm run devit increases to 244.2 mb is that normal?

04 Dec
9 months ago

abdulaziz started a new conversation Eloquent Eager Load

Hello, hope you are doing good! I have Tasks. Each Task has Status,Author and Assignee. The data must sorted by Statuses. I did it this way but I am sure there must be a better way.

$Statuses = Status::with('tasks.author','tasks.assignee')->get();

How do I say get statuses with its tasks which includes author and assignee of task? Thank you!

22 Nov
9 months ago

abdulaziz left a reply on Closure Based Routes?

@bobbybouwmann and how to cache routes if you are using Closure based routes?

21 Nov
9 months ago

abdulaziz left a reply on Closure Based Routes?

Had this error Unable to prepare route [api/user] for serialization. Uses Closure. Commented this line in routes/api.php:

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Executed php artisan route:cache and it worked. @bobbybouwmann Thank you very much!

abdulaziz left a reply on Closure Based Routes?

@bobbybouwmann How do I rewrite this as non closure route:

Route::prefix('admin')->middleware('auth')->group(function () {
    Route::resource('posts','PostController');
});

Please help

15 Nov
10 months ago

abdulaziz left a reply on Trying To Include Material-design-icon In App.css

Solved it. Mistake was:

@import '~material-design-icons/iconfont/material-icons.css';

Thank you @rizqyhi

abdulaziz started a new conversation Trying To Include Material-design-icon In App.css

Installed npm install material-design-icons Included the following line in my app.scss(not sure if it is correct):

@import '~/node_modules/material-design-icons/iconfont/material-icons.css';

Have this in my blade:

<i class="material-icons">face</i>

Get this error in my console: http://app.test/node_modules/material-design-icons/iconfont/material-icons.css net::ERR_ABORTED 404 (Not Found) Please help

12 Nov
10 months ago

abdulaziz left a reply on All Problems With The New Laracasts Design

Pop up notification disappears really fast!

Is it just me or now you can not watch any videos without subscription

10 Nov
10 months ago

abdulaziz left a reply on Named Routes In Vue

@wilk_randall Thank you will definitely look at it

09 Nov
10 months ago

abdulaziz left a reply on Named Routes In Vue

I wonder how others do it

abdulaziz left a reply on Named Routes In Vue

@CMDOBUENO - Thanks, never thought about it that way .

abdulaziz started a new conversation Named Routes In Vue

What is the proper way of using named routes in Vue?

abdulaziz left a reply on 500 Error On Root Route Of Prefix

@j3rik0 Now I got what you meant )

abdulaziz left a reply on 500 Error On Root Route Of Prefix

The prefix method may be used to prefix each route in the group with a given URI. For example, you may want to prefix all route URIs within the group with admin:

Route::prefix('admin')->group(function () {
    Route::get('users', function () {
        // Matches The "/admin/users" URL
    });
});

So I assume if you want to go to / the Route::get('/', '[email protected]'); must be outside of the prefix group?

abdulaziz left a reply on 500 Error On Root Route Of Prefix

Can not go this users profile page @j3rik0. Mr @jeffreyway is this a bug?

abdulaziz left a reply on 500 Error On Root Route Of Prefix

Shouldn't it be dashboard/ because you have a prefix there?

abdulaziz left a reply on Where Are You All From?

Dushanbe, Tajikistan ;)

abdulaziz left a reply on Trying To Use Moment.js

I ended up doing this:

<template>
    <div>
            {{ moment().format('MMM Do YYYY') }}
    </div>
</template>

<script>
  import moment from 'moment';

export default {
      methods:{
        moment(arg) {
             return moment(arg);
         }  
      }
}
</script>

abdulaziz left a reply on Trying To Use Moment.js

Thank you all, you are the best!

abdulaziz left a reply on Trying To Use Moment.js

After what @sahibalejandro told not sure if it is a good way but It is working this way

<script>
    export default {
        data:()=>({
            moment: require('moment')
        })
        }
</script>

abdulaziz left a reply on Trying To Use Moment.js

@ANDREA95 - Thanks for the hint but I need moment because I will do some data manipulations later on.

abdulaziz left a reply on Trying To Use Moment.js

@BOBBYBOUWMANN - Thanks all, for replies! Did everything as you told me but still getting the same error :(

[Vue warn]: Property or method "moment" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> <User> at resources/js/components/users/show.vue
       <VContent>
         <VApp>
           <Root>

abdulaziz started a new conversation Trying To Use Moment.js

terminal:

npm install moment --save

app.js:

var moment = require('moment');

const app = new Vue({
    el: '#app',
    data:{
    moment: moment
   }
});

show.vue:

{{moment().format('LTS')}}

Error: Property or method "moment" is not defined on the instance but referenced during render

Am I doing something wrong?

08 Nov
10 months ago

abdulaziz left a reply on How To Avoid Repeating Yourself

Mr @jeffreyway I found a small bug. When I am on my own question's page and click any link then when I go back from the browser I can see the long Array of information. Just wanted to let you know.

abdulaziz left a reply on How To Avoid Repeating Yourself

Mr @jeffreyway Love you Sir! New Design looks amazing btw!!!

abdulaziz left a reply on How To Avoid Repeating Yourself

Thank you all, you are the best!

abdulaziz started a new conversation How To Avoid Repeating Yourself

I want to have this:

    public function show(User $user)
    {
    //
    }

    public function edit(User $user)
    {
        //
    }

    public function update(Request $request,User $user)
    {
        //
    }

    public function destroy(User $user)
    {
        //
    }

Instead of this:

    public function show($id)
    {
        $user = User::find($id);
        //
    }

    public function edit($id)
    {
        $user = User::find($id);
        //
    }
    public function update(Request $request, $id)
    {
        $user = User::find($id);
        //
    }
    public function destroy($id)
    {
        $user = User::find($id);
        //
    }

How to achieve this functionality please help. Thank you!

01 Nov
10 months ago

abdulaziz left a reply on Attach Array For All Views.

Merci Boku!

abdulaziz started a new conversation Attach Array For All Views.

Sorry if it is a stupid question, How do I send an array for all my routes that will be used in views? Something like a sidebar list.

26 Jul
2 years ago

abdulaziz left a reply on The Cat Img Must Be A File Of Type: Jpg, Jpeg, Png.

try this

public function rules()
{
    return [
        'cat_img' => 'required|image|file'
    ];
}
14 Jul
2 years ago

abdulaziz started a new conversation Best Way To Make Multiple Categories Item Database Structure

Imagine a store with all kinds of different product. Each product has a category with many subcategories. One can have only one subcategory while the other one can have 3 subcategory. Example from Amazon:

Electronics, Computers & Office
    Musical Instruments
        Guitars
            Electronic Guitar
            Acoustic Guitar
    Monitors
    Computers & Tablets
        Tablets
        Laptops
        Desktops
            Gaming
            Home
            Work

So: Monitors have one category level

Electronics, Computers & Office > Monitors

Tablets two category levels

Electronics, Computers & Office > Computers & Tablets > Tablets

And Electronic Guitar Three category levels

Electronics, Computers & Office > Musical Instruments > Guitars > Electronic Guitar

The question is what is the best way to achieve this structure (considering the flexibility, maintenance, accessibility etc)? Somewhere I saw this structure:

Categories table
-------------------------------------------------------
| id | title                            | caregoty_id |
-------------------------------------------------------
| 1  | Electronics, Computers & Office  | 0           |
| 2  | Musical Instruments              | 1           |
| 3  | Guitars                          | 2           |
| 4  | Electronic Guitar                | 3           |
| 5  | Acoustic Guitar                  | 3           |
| 6  | Monitors                         | 1           |
| 7  | Computers & Tablets              | 1           |
| 8  | Tablets                          | 7           |
| 9  | Laptops                          | 7           |
-------------------------------------------------------

As you can see there is only one table which has a relationship with itself. I don't know if it is the correct way of doing it. Should I go with this idea or I should do it with more preemptive way by making Categories table like: categores1, categories2, categories3 ... where they have One To Many relationship. More subcategories more tables I will have. But I think it will be difficult to SELECT data from them because we won't know how many subcategories one item have.

Are these ways are correct? Which one should I use or is there a better way to do it? Thank you!

11 Jul
2 years ago

abdulaziz left a reply on Many To Many Working Oneway Only

I assume that you have some kind of simple mistake in your relationship. I did exactly what you did and it worked. I know you did it many times but recheck your code?

User.php

public function companies()
   {
       return $this->belongsToMany('App\Company');
   }

Company.php

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

CompaniesController.php

$company= new Company;
        $company->company_name="Test Name";
        $company->company_address="Test Address";
        $company->company_phone="9023840928";
        $company->save();
        $user=Sentinel::check();
        $user->companies()->attach($company->id);
        return redirect('home');

Migration

Schema::create('company_user', function (Blueprint $table) {
            $table->integer('company_id')->unsigned();
            $table->integer('user_id')->unsigned();

            $table->primary(['company_id', 'user_id']);
        });

abdulaziz started a new conversation Fire Update Event When Attach Is Called

I have two models Users and Roles. They have Many to Many relationship. There is also one Observer for User model. I want update event to be fired when I change User's Role.

UserObserver.php

<?php

namespace App\Observers;

use App\User;

class UserObserver
{
    public function deleting(User $user)
    {
        $user->stores()->detach();
    }

    public function updating(User $user)
    {
        // dd("Updating worked");
    }
}

User.php


//****//

public function setRole( $role_id )
    {
        // Get rid of All Roles that is assosiated with the user
            $this->deleteRoles();
        // Get Users role
            $role = Sentinel::findRoleById( $role_id );
        // Assign User role to User
            $role->users()->attach($this);

    // Fire updating event here ???
            
    }

//****//

Thanks in advance!

29 Apr
2 years ago

abdulaziz started a new conversation Your Requirements Could Not Be Resolved To An Installable Set Of Packages.

Getting this error while installing laravel/socialite

composer require laravel/socialite
Using version ^3.0 for laravel/socialite
./composer.json has been updated
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
    - Conclusion: remove laravel/framework v5.3.31
    - Conclusion: don't install laravel/framework v5.3.31
    - laravel/socialite v3.0.0 requires illuminate/http ~5.4 -> satisfiable by illuminate/http[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.9].
    - laravel/socialite v3.0.2 requires illuminate/http ~5.4 -> satisfiable by illuminate/http[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.9].
    - laravel/socialite v3.0.3 requires illuminate/http ~5.4 -> satisfiable by illuminate/http[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.9].
    - laravel/socialite v3.0.4 requires illuminate/http ~5.4 -> satisfiable by illuminate/http[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.9].
    - laravel/socialite v3.0.5 requires illuminate/http ~5.4 -> satisfiable by illuminate/http[v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.9].
    - don't install illuminate/http v5.4.0|don't install laravel/framework v5.3.31
    - don't install illuminate/http v5.4.13|don't install laravel/framework v5.3.31
    - don't install illuminate/http v5.4.17|don't install laravel/framework v5.3.31
    - don't install illuminate/http v5.4.19|don't install laravel/framework v5.3.31
    - don't install illuminate/http v5.4.9|don't install laravel/framework v5.3.31
    - Installation request for laravel/framework (locked at v5.3.31, required as 5.3.*) -> satisfiable by laravel/framework[v5.3.31].
    - Installation request for laravel/socialite ^3.0 -> satisfiable by laravel/socialite[v3.0.0, v3.0.2, v3.0.3, v3.0.4, v3.0.5].


Installation failed, reverting ./composer.json to its original content.

composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.3.*",
        "cartalyst/sentinel": "2.0.*",
        "nexmo/laravel": "^0.4.0"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~5.0",
        "symfony/css-selector": "3.1.*",
        "symfony/dom-crawler": "3.1.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

Please help