VinayPrajapati

Member Since 11 Months Ago

Experience Points
3,530
Total
Experience

1,470 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
10
Lessons
Completed
Best Reply Awards
3
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

  • Community Pillar

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

Level 1
3,530 XP
Apr
08
5 days ago
Activity icon

Replied to Get Dynamic Value Of Data In Vuejs

This is just a example, i have more than that, not only this two.

This is bad practice to check if statement every time.

Activity icon

Replied to Get Dynamic Value Of Data In Vuejs

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval

Warning: Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you use eval(). See Never use eval()!, below.

Activity icon

Started a new Conversation Get Dynamic Value Of Data In Vuejs

data: {
    Index:{
		time: '00:00:05.000'
		timeBegan = null,
	},
	About:{
		time: '00:00:10.000'
		timeBegan = null,
	}
 }
methods: {
    getTime(param) {
		// param = Index / About
     	console.log(this.data.param.time); // i want get dynamic value of data if Index pass as param then '00:00:05.000' or About pass as param then '00:00:10.000';
    },
}

Hoe can i achive this. get dynamic value as per param.

Mar
25
2 weeks ago
Activity icon

Started a new Conversation Apply Authorization In User Model By Specific Permission Based On Role.

Any optimal solution for this scenario.

i given permission to User Model based on role, authorized by policy.

Super Admin (Role Super Admin - User Model)  

1. Have all rights,

Admin (Role Admin - User Model)  

1. 'view-student',
2. 'create-student'
3. 'edit-student'
4. 'delete-student'

5. 'view-teacher'
6. 'create-teacher'
7. 'edit-teacher'
8. 'delete-teacher'

Teacher (Role Teacher- User Model)  

Given permission

1. 'view-student',
2. 'create-student'
3. 'edit-student'

Here teacher can't delete student

Student (Role Student - User Model)

1. 'view-student'

2. 'view-teacher'

Activity icon

Replied to Multiple Policy For User Model

@Snapey

can you sugggest for this scenario.

Activity icon

Replied to Multiple Policy For User Model

@martinbean


can you sugggest for this scenario.

i given permission to User Model based on role, authorized by policy.

Super Admin (Role Super Admin - User Model)  

1. Have all rights,

Admin (Role Admin - User Model)  

1. 'view-student',
2. 'create-student'
3. 'edit-student'
4. 'delete-student'

5. 'view-teacher'
6. 'create-teacher'
7. 'edit-teacher'
8. 'delete-teacher'

Teacher (Role Teacher- User Model)  

Given permission

1. 'view-student',
2. 'create-student'
3. 'edit-student'

Here teacher can't delete student

Student (Role Student - User Model)

1. 'view-student'

2. 'view-teacher'

Mar
23
3 weeks ago
Activity icon

Replied to Multiple Policy For User Model

@martinbean Yes,

I'm reading your reply,

I have only one User Model with different role based user.

i want to give specific permission to all role based user and authorize by policy

Activity icon

Replied to Multiple Policy For User Model


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

// Will invoke StudentPolicy::update method

 $this->authorize('update', $student);  // Will invoke AdminPolicy::update method not  StudentPolicy::update 
Activity icon

Replied to Multiple Policy For User Model

Insted of call in every methods in controller, how can i refactore to another file like policy?

Activity icon

Replied to Multiple Policy For User Model

I want to authorized policy by permissions,

I have super-admin who have all rights,

AdminPolicy works fine for single admin role.

admin can

create-teacher, update-teacher, etc // Super admin assign permission

teacher can

create-student, update-student, etc // Super admin assign permission

student can

view-student, view-teacher, etc // Super admin assign permission

i have users with role admin, teacher and student.

for student and teacher i want make policy but may be it's not possible.

Now i check in every method for seprate permission for StudentController and TeacherController

<?php

namespace App\Http\Controllers\User;

use App\Actions\Student\AddStudent;
use App\Actions\Student\UpdateStudent;
use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class StudentController extends Controller
{

    /**
     * Instantiate a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
        abort_if(! auth()->user()->can('create-student'), 403);
        $user = AddStudent::add($request->all());
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\User  $student
     * @return \Illuminate\Http\Response
     */
    public function edit(User $student)
    {
        abort_if(! auth()->user()->can('edit-student'), 403);
        $student = User::find($student->id);
        return response()->json([
            'student' => $student,
        ]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\User  $student
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, User $student)
    {
        abort_if(! auth()->user()->can('edit-student'), 403);
        $student = UpdateStudent::update($request->all(), $student);
        
        return response()->json([
            'student' => $student
        ]);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\User  $student
     * @return \Illuminate\Http\Response
     */
    public function destroy(User $student)
    {
        abort_if(! auth()->user()->can('delete-student'), 403);
        $student->delete();

        return response()->json([
            'success' => $student
        ]);
    }
}

Any other optimal solution.

Activity icon

Replied to Multiple Policy For User Model

Is there any way to what i want to achive?

Activity icon

Replied to Multiple Policy For User Model

How can i make policy for user, Like, StudentPolicy and TeacherPolicy For User Model, Or Some other option.

Activity icon

Awarded Best Reply on Refactoring Code

In Trait

namespace App\Traits; 

use App\Models\Category;
use App\Models\Tag;

trait TraitName
{
    public static function getCategory()
    {
        return Category::select('id', 'name')->get();
    }

    public static function getTags()
    {
        return Tag::select('id', 'name')->get();
    }
}

in Model

namespace App\Models;

class ModelName extends Model
{
	use TraitName;
}

In Controller

/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return response()->json([
            'categories' => Category::getCategory(),
	    'tags' => Tag::getTags()
        ]);
    }


     /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Blog  $blog
     * @return \Illuminate\Http\Response
     */
    public function edit(Blog $blog)
    {
        return response()->json([
	    'blog' => $blog,
            'categories' => Category::getCategory(),
	    'tags' => Tag::getTags()
        ]);
    }

This will now be a bit DRYer.

Activity icon

Awarded Best Reply on Got Error Constant Expression Contains Invalid Operations

I have used "laravel/ui"

'home' => route('dashboard'),

above code generate error

In UrlGenerator.php line 120:

  Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in C:\wamp64\www\master-sms\vendor\laravel\framework\src\Illuminate\Rou
  ting\RoutingServiceProvider.php on line 65

so insted of this i used this

'home' => 'admin.dashboard',

in my controller

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
	    $this->redirectTo = route(config('filename.home'));
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\Models\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }
}

Activity icon

Started a new Conversation Multiple Policy For User Model

I have different permissions like this

'view-admin'
'create-admin'
'edit-admin'
'delete-admin'

'view-student',
'create-student'
'edit-student'
'delete-student'

'view-teacher'
'create-teacher'
'edit-teacher'
'delete-teacher'

i register policy in my AuthServiceProvider

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Models\User' => 'App\Policies\Admin\AdminPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();
    }
}


in my AdminPolicy

<?php

namespace App\Policies\Admin;

use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;

class AdminPolicy
{
    use HandlesAuthorization;

    /**
     * Determine whether the user can view any models.
     *
     * @param  \App\User  $user
     * @return mixed
     */
    public function viewAny(User $user)
    {
        if ($user->can('view-admin')) {
            return true;
        }
    }

    /**
     * Determine whether the user can view the model.
     *
     * @param  \App\User  $user
     * @param  \App\User  $model
     * @return mixed
     */
    public function view(User $user, User $model)
    {
        if ($user->can('view-admin')) {
            return true;
        }
    }

    /**
     * Determine whether the user can create models.
     *
     * @param  \App\User  $user
     * @return mixed
     */
    public function create(User $user)
    {
        if ($user->can('create-admin')) {
            return true;
        }
    }

    /**
     * Determine whether the user can update the model.
     *
     * @param  \App\User  $user
     * @param  \App\User  $model
     * @return mixed
     */
    public function update(User $user, User $model)
    {
        if ($user->can('edit-admin')) {
            return true;
        }
    }

    /**
     * Determine whether the user can delete the model.
     *
     * @param  \App\User  $user
     * @param  \App\User  $model
     * @return mixed
     */
    public function delete(User $user, User $model)
    {
        if ($user->can('delete-admin')) {
            return true;
        }
    }

    /**
     * Determine whether the user can restore the model.
     *
     * @param  \App\User  $user
     * @param  \App\User  $model
     * @return mixed
     */
    public function restore(User $user, User $model)
    {
        //
    }

    /**
     * Determine whether the user can permanently delete the model.
     *
     * @param  \App\User  $user
     * @param  \App\User  $model
     * @return mixed
     */
    public function forceDelete(User $user, User $model)
    {
        //
    }
}

i have role admin,student,teacher. i want to make policy for student and teacher, How can i achieve this.

Activity icon

Replied to Got Error Constant Expression Contains Invalid Operations

I have used "laravel/ui"

'home' => route('dashboard'),

above code generate error

In UrlGenerator.php line 120:

  Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in C:\wamp64\www\master-sms\vendor\laravel\framework\src\Illuminate\Rou
  ting\RoutingServiceProvider.php on line 65

so insted of this i used this

'home' => 'admin.dashboard',

in my controller

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
	    $this->redirectTo = route(config('filename.home'));
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\Models\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }
}

Mar
14
4 weeks ago
Activity icon

Replied to Got Error Constant Expression Contains Invalid Operations

Route::prefix(config('config.admin_prefix'))->namespace('Admin')->name('admin.')->group(function () {
    Auth::routes(['register' => false]);
});

Route::prefix(config('config.admin_prefix'))->middleware(['auth'])->namespace('Admin')->name('admin.')->group(function () {
    Route::get('/dashboard', '[email protected]')->name('dashboard');
    /* User */
});

Here if i change admin prefix in config file, I also change dashboard route every time in RouteServiceProvider. So i want to dynamic this.

Activity icon

Started a new Conversation Got Error Constant Expression Contains Invalid Operations

Got error Constant expression contains invalid operations

In RouteServiceProvider when add route helper

    /**
     * The path to the "home" route for your application.
     *
     * This is used by Laravel authentication to redirect users after login.
     *
     * @var string
     */
    public const HOME = '/home';

	public const HOME = "'".route("dashboard")."'"; // i want to dynamic this

Mar
12
1 month ago
Activity icon

Replied to PHP Logical Operators

'ClientReference' => ($this->options['clientref'] ? $this->options['clientref'] .'-'. : '').$this->filterOrderId($order)

Use this.

Mar
11
1 month ago
Activity icon

Awarded Best Reply on Yajra Datatable - How To Insert Html Code In A Field?

->editColumn('field', '<strong>{{$field}}</strong>')->rawColumns(['field'])->make(true);

Add this in you code

Activity icon

Replied to Yajra Datatable - How To Insert Html Code In A Field?

->editColumn('field', '<strong>{{$field}}</strong>')->rawColumns(['field'])->make(true);

Add this in you code

Feb
25
1 month ago
Activity icon

Started a new Conversation Run Code As Per Github Branches


Assume i have domain http://www.abc.com

In github i have three branches

test1
test2
test3


http://www.abc.com/test1  // run_code per test1 branch
http://www.abc.com/test2  // run_code per test2 branch
http://www.abc.com/test3  // run_code per test3 branch

Feb
05
2 months ago
Activity icon

Started a new Conversation Make Crossword And Search Word

I want to make crossword 15*15,

Put random word upto(15)

HORIZONTAL VERTICAL DIAGONAL

And Search.

Any Suggestion.

Feb
01
2 months ago
Activity icon

Started a new Conversation Convert Minutes In To Hours

Convert minutes in to like below

1 => 1 minute
15 => 15 minutes
60 => 1 Hour
65 => 1 Hour 5 minutes
125 => 2 Hours 5 minutes

Now I`m doing in blade like this.

{{ ((intdiv($time_in_minute , 60) > 0) ? intdiv($time_in_minute , 60) .' hr' : '') .((($time_in_minute % 60) > 0 && intdiv($time_in_minute , 60) > 0) ? ' and ' : ''). ((($time_in_minute % 60) > 0) ? (($time_in_minute % 60 <=1 ) ? ($time_in_minute % 60) .' minute' : ($time_in_minute % 60) .' minutes') : '')}}

Is there any best way to refactor.

Jan
31
2 months ago
Activity icon

Started a new Conversation Phph Artisan Vendor:publish Input Getting Aborted Instantly

C:\wamp64\www\demo>php artisan vendor:publish

 Which provider or tag's files would you like to publish?:
  [0 ] Publish files from all providers and tags listed below
  [1 ] Provider: Facade\Ignition\IgnitionServiceProvider
  [2 ] Provider: Fideloper\Proxy\TrustedProxyServiceProvider
  [3 ] Provider: Fruitcake\Cors\CorsServiceProvider
  [4 ] Provider: Illuminate\Foundation\Providers\FoundationServiceProvider
  [5 ] Provider: Illuminate\Mail\MailServiceProvider
  [6 ] Provider: Illuminate\Notifications\NotificationServiceProvider
  [7 ] Provider: Illuminate\Pagination\PaginationServiceProvider
  [8 ] Provider: JamesDordoy\LaravelVueDatatable\Providers\LaravelVueDatatableServiceProvider
  [9 ] Provider: Laravel\Sanctum\SanctumServiceProvider
  [10] Provider: Laravel\Tinker\TinkerServiceProvider
  [11] Provider: Spatie\Permission\PermissionServiceProvider
  [12] Tag: config
  [13] Tag: cors
  [14] Tag: flare-config
  [15] Tag: ignition-config
  [16] Tag: laravel-errors
  [17] Tag: laravel-mail
  [18] Tag: laravel-notifications
  [19] Tag: laravel-pagination
  [20] Tag: migrations
  [21] Tag: sanctum-config
  [22] Tag: sanctum-migrations
 >

  Aborted.
[2021-01-31 11:37:12] local.ERROR: Aborted. {"exception":"[object] (Symfony\Component\Console\Exception\MissingInputException(code: 0): Aborted. at C:\wamp64\www\demo\vendor\symfony\console\Helper\QuestionHelper.php:134)
[stacktrace]
#0 C:\wamp64\www\demo\vendor\symfony\console\Helper\QuestionHelper.php(68): Symfony\Component\Console\Helper\QuestionHelper->doAsk(Object(Illuminate\Console\OutputStyle), Object(Symfony\Component\Console\Question\ChoiceQuestion))
#1 C:\wamp64\www\demo\vendor\symfony\console\Helper\QuestionHelper.php(469): Symfony\Component\Console\Helper\QuestionHelper->Symfony\Component\Console\Helper\{closure}()
#2 C:\wamp64\www\demo\vendor\symfony\console\Helper\QuestionHelper.php(71): Symfony\Component\Console\Helper\QuestionHelper->validateAttempts(Object(Closure), Object(Illuminate\Console\OutputStyle), Object(Symfony\Component\Console\Question\ChoiceQuestion))
#3 C:\wamp64\www\demo\vendor\symfony\console\Style\SymfonyStyle.php(365): Symfony\Component\Console\Helper\QuestionHelper->ask(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle), Object(Symfony\Component\Console\Question\ChoiceQuestion))
#4 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Console\Concerns\InteractsWithIO.php(212): Symfony\Component\Console\Style\SymfonyStyle->askQuestion(Object(Symfony\Component\Console\Question\ChoiceQuestion))
#5 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Foundation\Console\VendorPublishCommand.php(111): Illuminate\Console\Command->choice(Object(Symfony\Component\Console\Question\ChoiceQuestion), Array)
#6 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Foundation\Console\VendorPublishCommand.php(98): Illuminate\Foundation\Console\VendorPublishCommand->promptForProviderOrTag()
#7 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Foundation\Console\VendorPublishCommand.php(73): Illuminate\Foundation\Console\VendorPublishCommand->determineWhatShouldBePublished()
#8 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Illuminate\Foundation\Console\VendorPublishCommand->handle()
#9 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Container\Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#10 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#11 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#12 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Container\Container.php(610): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#13 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Console\Command.php(136): Illuminate\Container\Container->call(Array)
#14 C:\wamp64\www\demo\vendor\symfony\console\Command\Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#15 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Console\Command.php(121): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#16 C:\wamp64\www\demo\vendor\symfony\console\Application.php(971): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 C:\wamp64\www\demo\vendor\symfony\console\Application.php(290): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Foundation\Console\VendorPublishCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 C:\wamp64\www\demo\vendor\symfony\console\Application.php(166): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Console\Application.php(93): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 C:\wamp64\www\demo\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(129): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 C:\wamp64\www\demo\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 {main}
"} 
Jan
22
2 months ago
Activity icon

Replied to Use % Wildcard In WhereJsonContains

Try direct this


$query->orWhereRaw("lower(info) like ?", ['%"skills":"'.strtolower($term).'"%'])
        ->orWhereRaw("lower(info) like ?", ['%"interests":"'.strtolower($term).'"%'])
        ->latest();

Activity icon

Replied to Use % Wildcard In WhereJsonContains

In Your model

public function scopeSearch($query, $value) 
    {
        $query->orWhereRaw("lower(info) like ?", ['%"skills":"'.strtolower($value).'"%'])
        ->orWhereRaw("lower(info) like ?", ['%"interests":"'.strtolower($value).'"%'])
        ->latest();
    }

in controller

$query->search($term);

Activity icon

Replied to Laravel Selected Dropdown Value When Edit

Install Laravel Collective

https://laravelcollective.com/docs/6.x/html

than just this.


{{Form::select("avocat_wilaya", $avocat['wilaya_avocat'], null , ['class'=>'form-control'])}}

Jan
21
2 months ago
Activity icon

Replied to Npm Run Dev: Module Build Failed, TypeError

 "postcss-import": "^13.0.0",

manualy

npm intalll & npm run dev

Activity icon

Replied to Npm Run Dev: Module Build Failed, TypeError

Show me your package.json file.

Jan
20
2 months ago
Activity icon

Replied to Npm Run Dev: Module Build Failed, TypeError

please try this

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
Jan
16
2 months ago
Activity icon

Replied to Refactoring Code

In Trait

namespace App\Traits; 

use App\Models\Category;
use App\Models\Tag;

trait TraitName
{
    public static function getCategory()
    {
        return Category::select('id', 'name')->get();
    }

    public static function getTags()
    {
        return Tag::select('id', 'name')->get();
    }
}

in Model

namespace App\Models;

class ModelName extends Model
{
	use TraitName;
}

In Controller

/**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return response()->json([
            'categories' => Category::getCategory(),
	    'tags' => Tag::getTags()
        ]);
    }


     /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Blog  $blog
     * @return \Illuminate\Http\Response
     */
    public function edit(Blog $blog)
    {
        return response()->json([
	    'blog' => $blog,
            'categories' => Category::getCategory(),
	    'tags' => Tag::getTags()
        ]);
    }

This will now be a bit DRYer.

Activity icon

Started a new Conversation Vuejs Integrate Datatable

Vue js integrate datatble,

Any package for best recommended?

Activity icon

Replied to Refactoring Code

I forgot to say,

it's SPA, i'm using vuejs,how can i share it with view composer.

Activity icon

Replied to Refactoring Code

May be View Composer working only in View does not for the json reponse,

Let me try first View Composer for json response.

Activity icon

Started a new Conversation Refactoring Code

     /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        
        $categories = Category::select('id', 'name')->get();  // Repeated
	$tags = Tag::select('id', 'name')->get(); // Repeated
       
        return response()->json([
            'categories' => $categories,
	    'tags' => $tags,
        ]);
    }


     /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Blog  $blog
     * @return \Illuminate\Http\Response
     */
    public function edit(Blog $blog)
    {
        $categories = Category::select('id', 'name')->get(); // Repeated
	$tags = Tag::select('id', 'name')->get(); // Repeated
       
        return response()->json([
	    'blog' => $blog,
            'categories' => $categories,
	    'tags' => $tags,
        ]);
    }

I want to refactor this repeated code,

How can i achive this?

Jan
15
2 months ago
Activity icon

Awarded Best Reply on Undefined Variable Problem

return view('aboutmes.edit', ['aboutmes'=>$aboutme]);
								^
                                                       // This one access in view file

// changes to this        

return view('aboutmes.edit', ['aboutme'=>$aboutme]);

Activity icon

Replied to How To Get Only Specific Year In Laravel

$date->format('Y');
Activity icon

Replied to Undefined Variable Problem

return view('aboutmes.edit', ['aboutmes'=>$aboutme]);
								^
                                                       // This one access in view file

// changes to this        

return view('aboutmes.edit', ['aboutme'=>$aboutme]);

Activity icon

Started a new Conversation Title Tag Change In Vuejs.

<title>Laravel</title>

Beast way to change title tag dynamically in vuejs.

I use following

// In app.js
import VueMeta from 'vue-meta'

Vue.use(VueMeta)

// in vue file

<template>
  <div>
  </div>
</template>

<script>
export default {
  metaInfo: { title: 'Dashboard' },
};
</script>

It's change document title, not actual title tag (Source Code).

Jan
11
3 months ago
Activity icon

Replied to Hide Laravel Artisan Command Until It's Finished.

I want to actually remove the command from the artisan list when it's execute,

After execution is completed it's show again as regular.

Activity icon

Replied to Hide Laravel Artisan Command Until It's Finished.

Is there any first_party mutex for Console\Command?

Jan
08
3 months ago
Activity icon

Awarded Best Reply on Validation Error Not Working Laravel

     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'ordernumber' => ['required', 'string', 'regex:/(^DV90[0-9]{8}$)|(^RA90[0-9]{8}$)|(^Ra90[0-9]{8}$)|(^Dv90[0-9]{8}$)|(^3[0-9]{7}$)/', 'unique:orders,ordernumber'],
            'email' => 'required|email|max:200',
            'numberplate' => 'required',
            ];

    }
	
/**
     * Get the error messages for the defined validation rules.
     *
     * @return array
     */
    public function messages()
    {
        return [
            'numberplate.required' => 'Parkeervaknummer is vereist',
        ];
    }

Activity icon

Replied to Validation Error Not Working Laravel

     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'ordernumber' => ['required', 'string', 'regex:/(^DV90[0-9]{8}$)|(^RA90[0-9]{8}$)|(^Ra90[0-9]{8}$)|(^Dv90[0-9]{8}$)|(^3[0-9]{7}$)/', 'unique:orders,ordernumber'],
            'email' => 'required|email|max:200',
            'numberplate' => 'required',
            ];

    }
	
/**
     * Get the error messages for the defined validation rules.
     *
     * @return array
     */
    public function messages()
    {
        return [
            'numberplate.required' => 'Parkeervaknummer is vereist',
        ];
    }

Activity icon

Replied to Laravel Collection Filter

Need to show more code.

Activity icon

Replied to Laravel Collection Filter

Please check instead of $account->$col use $account->{$col}

Activity icon

Replied to Laravel Collection Filter

may be you forgot return please check public function filter($col, $val) { $this->accounts = $this->accounts->filter(function($account) use ($col, $val) { return $account->$col == $val; }); }