tashari

tashari

Director/Designer/Developer at Tashari Web Development

Member Since 3 Years Ago

Benoni

Experience Points
118,130
Total
Experience

1,870 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
1123
Lessons
Completed
Best Reply Awards
2
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.

Level 24
118,130 XP
Apr
20
1 month ago
Activity icon

Replied to Property [name] Does Not Exist On This Collection Instance.

public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required|min:3',
            'time' => 'required|min:3',
            'description' => 'required|min:10',
            'file' => 'required|file|max:2048'
        ]);

        if (Auth::check()) {
             $upload = $request->file('file');
             $path = $upload->store('public/storage/graphics');

            $file = Graphic::create([
                 'name' => $request->name,
                 'time' => $request->time,
                 'description' => $request->description,
                 'file_title' => $upload->getClientOriginalName(),
                 'file' => $path,
                 'user_id' => Auth::user()->id
             ]);

     
            return redirect('Payment/[email protected]',['id' => $file->id]);

		// you can grab the id from the newly created resource - $file
        }

	//if auth::check() fails then what
        
    }



Route::get('/graphics.payment/{id}', 'Payment/[email protected]')->name('payment');


public function index ($id)
    {
             $graphics = Graphic::findOrFail($id);
        
        return view('guavahire.graphics.payment')->with([

            'graphics' => $graphics
    
        ]);
    }
  

Apr
19
1 month ago
Activity icon

Replied to Property [name] Does Not Exist On This Collection Instance.

Apologies for formatting as this was posted from my phone

Activity icon

Replied to Property [name] Does Not Exist On This Collection Instance.

Use this in the bottom of the storw method. 


return redirect()->action('[email protected]',['id' => $file-id]);


Then in show method

public function show($id) 
{

    Graphic::findOrFail($id);

      return view('guavahire.graphics.payment',compact('graphic');
}



Apr
18
1 month ago
Activity icon

Replied to Combining Blade And Vue

I use Vue for SPA development.

for small interactions Alpine.js

To handle ajax I now us Laravel/Livewire ..(by the creator of alpine.js) ... try it you will be blown away. You will be able to write your CRUD in a livewire component just as you do in a Laravel Controller and still have the benefits of ajax (no page reloads etc)

Apr
17
1 month ago
Activity icon

Replied to Combining Blade And Vue

if you doing mostly just reactive/interactive stuff I suggest you look at https://github.com/alpinejs/alpine similar syntax as vue but very straight forward and simple.

Perfect if you rendering everything with blade and you just need a sprinkle of js for interactivity

Activity icon

Replied to One Route Multiple Views Based On User Role

if you just want to limit access to certain functions in the dashboard and grant access to the rest.

You can use one dashboard view and just hide or display features needed.

try something like this

in User Model


public function isAdmin() 
{

	if(auth()->user()->role->name == 'admin'){
	
		return true;
	
	}

	return false;

}


public function isStaff() 
{

	if(auth()->user()->role->name == 'staff'){
	
		return true;
	
	}

	return false;

}




in dashboard view

	
@if( auth()->user()->isAdmin() )

	
	//functions for admin


@endif


@if( auth()->user()->isStaff() )

	
	//functions for Staff


@endif


you can also extract this to a custom Blade if

in AppServiceProvider

use Illuminate\Support\Facades\Blade;

Blade::if('admin', function () {
    return auth()->check() && auth()->user()->isAdmin();
});


Then in Dashboard View


@admin
    //functions for admin
@else
    //functions for everyone
@endadmin


Activity icon

Replied to One Route Multiple Views Based On User Role

its better practice to manage login in your controller and not Route file (web.php)

Activity icon

Replied to One Route Multiple Views Based On User Role

this should work as long as you have different named routes


Route::get('dashboard', '[email protected]')->name('dashboard.index');

Route::get('dashboard', '[email protected]')->name('staff.dashboard');

Route::get('dashboard', '[email protected]')->name('admin.dashboard');


in Dashboard Controller...


public function index() 
{
	if( auth()->user()->isAdmin() ){

		return redirect()->route('admin.dashboard');
	}

	return redirect()->route('staff.dashboard');
}

in Admin Dashboard Controller


public function index() 
{
	

	return view('admin.dashboard');

}



Activity icon

Replied to Property [name] Does Not Exist On This Collection Instance.

are you passing the graphic Id to the payment page

show me the method where it is redirected to the payment page

Activity icon

Replied to One Route Multiple Views Based On User Role

not sure if i understand 100% but this is how I normally handle it...

In Route file...


Route::get('dashboard', '[email protected]')->name('dashboard.index');

Route::get('staff/dashboard', '[email protected]')->name('staff.dashboard');

Route::get('admin/dashboard', '[email protected]')->name('admin.dashboard');


in User Model...

public function isAdmin() 
{

	if(auth()->user()->role->name == 'admin'){
	
		return true;
	
	}

	return false;

}


in Dashboard Controller...

public function index() 
{
	if( auth()->user()->isAdmin() ){

		return redirect()->route('admin.dashboard');
	}

	return redirect()->route('staff.dashboard');
}

Apr
11
1 month ago
Activity icon

Replied to How To Properly Validate Unique Field On Update

Not sure if there is a validation rule that handles that

When using unique it checks against the whole group table so it wont work

Maybe dont check that value in validation and check after it passes all other values.


if(request()->has('group_name')
{
   // get auth user groups
  // check if name exists

   flash error
    return;

}

Activity icon

Replied to How To Check If The User Used His First Name And Last Name In The Name Field Again ? Validation Rule

Dont use unique on first name and last name as stated by other members

On the name field use unique

You can also use alpha_dash as a rule on the name so that the user cant enter any spaces - has to be something like johnDoe123 and validation will fail if tries John Doe

Activity icon

Replied to Update Parameters Empty In Request

Do a dd(request->all()) before the validation to make sure you are hitting the correct route

Have you got @method('patch') on the form ?

Activity icon

Replied to How To Properly Validate Unique Field On Update


Rule::unique('groups')->ignore($group->name, 'group_id')

Apr
08
1 month ago
Activity icon

Replied to Property [name] Does Not Exist On This Collection Instance.

You will need to pass through the $id to the method, Find the graphic by $id and pass it to view

public function show($id) 
{

	return view('guavahire.graphics.payment')->with([

		'graphic' = Graphic::findOrFail($id)

	]);
}

Then in view you can just call

	
{{ $graphic->name }}

Apr
07
1 month ago
Activity icon

Replied to Property [name] Does Not Exist On This Collection Instance.

when you use

$graphics = Graphic::all();

it will return a collection of all graphics. You need to iterate over a collection with a forloop.

to get just the users graphics try,

@foreach(auth()->user()->graphics as $graphic)
	
	{{ $graphic->name }}

@endforeach

Activity icon

Replied to Property [name] Does Not Exist On This Collection Instance.

please be more specific.

Do you want to display just the users graphics or all graphics

Activity icon

Replied to Could Not Open Input File: Artisan

check folder structure

Apr
06
1 month ago
Activity icon

Awarded Best Reply on Getting My Head Around Eloquent Relationships

Make sure this is correct

$jobs = auth()->user()->jobs()->latest()->paginate(10);

Activity icon

Replied to Getting My Head Around Eloquent Relationships

Make sure this is correct

$jobs = auth()->user()->jobs()->latest()->paginate(10);

Activity icon

Replied to Getting My Head Around Eloquent Relationships

migrations look fine

Activity icon

Replied to Getting My Head Around Eloquent Relationships

Job migration must have user_id column

Activity icon

Replied to Getting My Head Around Eloquent Relationships

on User Model

public function jobs()
    {
        return $this->hasMany(Job::class);
    }


On Job Model


public function user()
    {
        return $this->belongsTo(User::class);
    }

Activity icon

Replied to Getting My Head Around Eloquent Relationships

a user has many jobs

a job belongs to a user

is this the relationship that you are hoping to get

Activity icon

Replied to Getting My Head Around Eloquent Relationships

public function user() {
		return $this->belongsTo(User::class, 'user_id', 'id');
	}

Activity icon

Replied to Getting My Head Around Eloquent Relationships

what error are you getting

Activity icon

Replied to Getting My Head Around Eloquent Relationships

$jobs = auth()->user()->jobs()->latest()->paginate(10);

Mar
29
2 months ago
Activity icon

Replied to How To Properly Save Image Path?

$person = $employee->person()->first(); 
Mar
21
2 months ago
Activity icon

Awarded Best Reply on After Update To Laravel 7 Php Artisan Not Working

Please make sure that you are not using any url() or asset() or other helpers functions inside your configuration files.

Activity icon

Replied to After Update To Laravel 7 Php Artisan Not Working

did you run composer update on live server?

Activity icon

Replied to After Update To Laravel 7 Php Artisan Not Working

Please make sure that you are not using any url() or asset() or other helpers functions inside your configuration files.

Mar
19
2 months ago
Activity icon

Replied to How To Enhance Live Site Speed

There are many factors that can slow down your site.

Check your image sizes and compress them.

Use browser caching

Look at the article on how to improve page speed through .htaccess

https://www.danielmorell.com/guides/htaccess-seo/page-speed/speed-up-your-site

give me a link to the site and I will see if I can help

Activity icon

Replied to Download Wont Start

I see you are trying to export the data to excel. you can achieve this very easily with an existing package

https://github.com/Maatwebsite/Laravel-Excel

Activity icon

Replied to Download Wont Start

try downloading directly in html

<a  href="{{ '/storage/'.   $document->link }}" download>
       Download File
</a>