niyo

niyo

Member Since 2 Months Ago

Experience Points
1,400
Total
Experience

3,600 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
2
Lessons
Completed
Best Reply Awards
0
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 1
1,400 XP
May
31
1 day ago
Activity icon

Replied to Preventrerouting Pages Without Permision

thanks men it worked am not opening the thing that i didn't creat so, it was only to change its position as i used it before

Activity icon

Replied to Preventrerouting Pages Without Permision

all looks the same have same things i use post on my testing project but wanted to show you well what am using please don't be confused

Activity icon

Replied to Preventrerouting Pages Without Permision

on my other model which i use the same thing

Route::resource('graphics', 'GraphicsController');
Route::get('/grthankyou/{id}', '[email protected]')->name('grthankyou');
Activity icon

Replied to Preventrerouting Pages Without Permision

so, what is the solution

Activity icon

Replied to Preventrerouting Pages Without Permision

App\Graphic {#437 ▼
  #fillable: array:8 [▼
    0 => "name"
    1 => "time"
    2 => "description"
    3 => "file"
    4 => "file_title"
    5 => "amount"
    6 => "amount_file"
    7 => "user_id"
  ]
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▼
    0 => "*"
  ]
}
2
null

this is what i got

Activity icon

Replied to Preventrerouting Pages Without Permision

@kalemdzievski yeah dump like how give me an example

Activity icon

Replied to Laravel Stripe API

yeah you can use it but first you need to register an account on stripe.com and get your api keys either live or test

Activity icon

Replied to Preventrerouting Pages Without Permision

the problem is not that one, now am using the same thing but its not working

public function view(User $user, Post $post)
    {
        return $user->id === $post->user_id;
    }

it was me who did this mistake while posting it so, the problem its steal the same

Activity icon

Replied to Preventrerouting Pages Without Permision

now the problem i have is if i create a post it show me this: 403 This action is unauthorized. i used all steps of creating a policy but it not working as i want

controller

public function post(Post $post, $id)
    {
        $this->authorize('view', $post);

        $post= Post::findOrFail($id);
        return view('discussion.post')->with([

            'post' => $post
    
        ]);
    }

in App\policies PostPolicies

class PostPolicy
{
    use HandlesAuthorization;
    
    /**
     * Determine whether the user can view any post.
     *
     * @param  \App\User  $user
     * @return mixed
     */
    public function viewAny(User $user)
    {
        //
    }

    /**
     * Determine whether the user can view the graphics.
     *
     * @param  \App\User  $user
     * @param  \App\Post $post
     * @return mixed
     */
    public function view(User $user, Post $Post)
    {
        return $user->id === $posts->user_id;
    }
}

AuthServiceProvider.php

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        Post::class => PostPolicy::class,
    ];

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

        //
    }
}
Activity icon

Replied to Preventrerouting Pages Without Permision

@kalemdzievski hey for example in my project i have four models that need to be protected will i use only class PostPolicy for all these models

Activity icon

Replied to Preventrerouting Pages Without Permision

@kalemdzievski will i use this class PostPolicy in User model or i will create a new model for it

Activity icon

Replied to Preventrerouting Pages Without Permision

i tried this also but it show me an error: $id

public function handle($request, Closure $next, $id)
    {
        
        if(Auth::user()->id == Post::find($id) || Auth::user()->id == cartegory::find($id))
        {
            return $next($request);
        } else {
            return back();
        }
    }

i saw also another one like mine but they told him to use policies i don't have no idea on how to make user polices please i need your help

Activity icon

Replied to Could Not Showing View.

@esaeng may be instead of bower use composer require admin-lte

Activity icon

Started a new Conversation Preventrerouting Pages Without Permision

i tried to create a middleware that could stop users to not view other users posts for example when a user created a post the post has an id so if he change his id to another users id's post he can view the post of another user

so, guyz its not like admin middleware i want make they are not the same, just not to get u confused

public function handle($request, Closure $next)
    {
        
        if(Auth::user()->id == Post::where('user_id', Auth::user()->id) || Auth::user()->id == cartegory::where('user_id', Auth::user()->id))
        {
            return $next($request);
        } else {
            return back();
        }
    }

protecting url

May
26
6 days ago
Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

yeah thanks bruh but right now i sorted it out like this

@if ($posts->amount == null)
        <p>wait to be given your post price amount</p>
@else 
    <a href="/posts.payment/{{ $posts->id }}" class="btn btn-primary">View Your  Payments</a>
@endif

and its working well as i wanted

thanks alot y' all that helped me out

Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

@jlrdw yeah i get it dude but what i mean there is related on my project for example my project works like this

you are my client you want to get any job done and hire someone like freelancers then you make a request for a job done so we work on it later we give you the price for your job done and we contact you by email that how it work so, if our client job is done his allowed to pay may when he/she get satisfied that's it

Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

@jlrdw am not getting you well are saying that instead of that paragraph i could use may be a pop up modal

Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

my friend i knew where the problem was thanks alot it was how i used to call my file in public folder it was to add only this stupid things : ../ , but by using view it never showed me an error

but my another problem is this one to get if a user is not yet given amount be shown this paragraph to wait and if his given the amount and refresh get the link down there

in givePrice.blade.php

@if ($results = DB::select('select * from posts where amount != null, id= $posts->id'))
        <p>wait to be given your post price amount</p>
@else 
    <a href="/posts.payment/{{ $posts->id }}" class="btn btn-primary">View Your  Payments</a>
@endif
May
25
1 week ago
Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

no am not using the app.css for laravel 5.8 and also am not even including an unrelated extinsion on givePrice page

but when i was using view it worked well

Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

what i found is when i use bootstrap 3 the whole extinsions are gone but if i paste in codes of bootstrap4 it works but am using bootstrap3 in my website i don't why it happens like that may be is my laravel version i use 5.8

Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

my problem is not about payment, the page with payment is on the other side of the one i have on a problem

by the way my payment i use is stripe and it works well, just read well if a user have been given the price he get the link that redirect him to the page of payments

Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

@snapey the redirect is working now but it changes my page's design it remove bootstrap, css, js.etc... all extinsions of this page and view html only

May
24
1 week ago
Activity icon

Replied to Laravel Saving Pages

men thanks it sorted out it work with this php artisan view:clear i used to clear my caches, config but finaly worked i never used view:clear

thanks alot

Activity icon

Replied to Laravel Saving Pages

@jlrdw how by displaying the whole page it is an html page, i have two different pages that have that problems its my login page, and another one of post.show page only other pages work perfect

Activity icon

Started a new Conversation Laravel Saving Pages

i tried to clear my caches, clear my routes but it steal the same i also erased something in my page it show me nothing i don't know what to do

Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

look what i used and correct me

public function store(Request $request, $id)
    {
        $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/posts');
        $posts = Post::create([
            'name' => $request->name,
            'time' => $request->time,
            'description' => $request->description,
            'file_title' => $upload->getClientOriginalName(),
            'file' => $path,
            'user_id' => Auth::user()->id
        ]);
            $id = Post::find($id);
            return redirect()->route('givePrice', [$id])->with(['posts' => $posts]);
        }
        
    }

the web.php

Route::resource('posts', 'PostController');
Route::get('/givePrice/{id}', '[email protected]')->name('givePrice');

this is givePrice controller's view

public function givePrice()
    {
        return view('posts.givePrice');
    }

the error that comes up is this one

Too few arguments to function App\Http\Controllers\PostController::store(), 1 passed and exactly 2 expected

thats why i use view and if i try to get this id does'nt work because am getting the id that is not yet created

please give me an example on how i can use redirect and goes with the same id of post that is just created

May
23
1 week ago
Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

@snapey I used redirect also but it doesn't work for me i use view to to continue with the post id i tried to redirect with post id but it doesn't get the post id in URL

May
21
1 week ago
Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

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/posts');
        $posts= Post::create([
            'name' => $request->name,
            'time' => $request->time,
            'description' => $request->description,
            'file_title' => $upload->getClientOriginalName(),
            'file' => $path,
            'user_id' => Auth::user()->id
        ]);
            return view('posts.givePrice', ['posts' => $posts]);
        }
        
    }

when if his/her post is created he goes on givePrice page and wait teel him/her is given the price then he reloads the page to get the link to continue to payment page guyz i need your help or any advice

May
15
2 weeks ago
Activity icon

Replied to Prevent Duplicate Record Insertion On Browser Refresh

@if ($results = DB::select('select * from posts where amount != null'))
        <p>wait to be given your post price amount</p>
@else 
    <a href="/posts.payment/{{ $posts->id }}" class="btn btn-primary">View Your  Payments</a>
@endif

please some body help me

Activity icon

Awarded Best Reply on Stripe How To Get Amount?

when i used the console i worked that's what i use thanks yah all for your help

Activity icon

Replied to Stripe How To Get Amount?

when i used the console i worked that's what i use thanks yah all for your help

Activity icon

Started a new Conversation Prevent Duplicate Record Insertion On Browser Refresh

my system is i create a post when am redirected to another page that ask me to wait for the admin to give me the order to continue and when i use admin panel to give the order that user to pass and give order him when if he reloads his page to be given the link it recreates a new post

please i need your help cause am confused on how i stop this

May
10
3 weeks ago
Activity icon

Replied to Redirect To?

@jlrdw thanks men i were confused but thanks alot bro

Activity icon

Replied to Stripe How To Get Amount?

hey right now my new error on that : Must provide source or customer.

array:6 [▼
  "amount" => 999
  "currency" => "usd"
  "description" => "Your work done info"
  "source" => null
  "receipt_email" => "[email protected]"
  "metadata" => array:1 [▶]
]

the problem is how can i get this source they show it's null

public function send(Request $request)
    {
        Stripe::setApiKey('sk_test_oql9ZKSYuxLCDg1iCkiqa00J0KLbWcd');
 
        Charge::create([
            'amount' => 999,
            'currency' => 'rwf',
            'description' => 'Your work done info',
            'source' => $request->stripeToken,
            'receipt_email' => $request->email,
            // Verify your integration in this guide by including this parameter
            'metadata' => [
                'order_id' => 3243,  
            ],
        ]);
        
        return back()->with('success', 'Thank you!! , Your payment was accepted');
    }

please help me am stuck

other problems were fixed just this one and also i have also the stripe token but i can't get it here it is

 // Submit the form with the token ID.
    function stripeTokenHandler(token) {
      // Insert the token ID into the form so it gets submitted to the server
      var form = document.getElementById('payment-form');
      var hiddenInput = document.createElement('input');
      hiddenInput.setAttribute('type', 'hidden');
      hiddenInput.setAttribute('name', 'stripeToken');
      hiddenInput.setAttribute('value', token.id);
      form.appendChild(hiddenInput);

      // Submit the form
      form.submit();
May
03
4 weeks ago
Activity icon

Replied to Stripe How To Get Amount?

i had this before it were working but i don't why it gives me this error

please help me to fix it

\Stripe\Stripe::setApiKey('STRIPE_SECRET_KEY')
\Stripe\Charge::create([
    'amount' => 1000,
    'currency' => 'rwf',
    'description' => 'Your work done info',
     'source' => $request->get('stripeToken'),
     'receipt_email' => $request->get('email'),
     // Verify your integration in this guide by including this parameter
     'metadata' => [
          'order_id' => 3243,  
      ],
]);

it steal the same

another error: Must provide source or customer.

May
02
4 weeks ago
Activity icon

Replied to Redirect To?

so the one on logincontroller i remove them then i put them in AuthenticatesUsers but i don't have a problem on these ones

if(Auth::user()->usertype == 'admin') 
        {
            return 'dashboard';
        } 
        elseif(Auth::user()->usertype == 'vendor')
        {
            return 'vendor-dashboard';
        }
Activity icon

Replied to Redirect To?

give me an example on how i can do it or use the trait

Activity icon

Replied to Redirect To?

look what i did but give me an error: View [post.graphics] not found.

protected function authenticated(Request $request, $user)
    {
        if(view('post.graphics'))
        {
            return 'graphics';
        }
    }

this view i have it also work well but it is giving me the error post.graphics

Activity icon

Replied to Redirect To?

should i write in authenticated function this:

Put code here to check the role.

if logged in user role is admin redirect to admin area
if logged in user role is blogger redirect to where ever area
if logged in user role is user redirect to user area
Activity icon

Replied to Stripe How To Get Amount?

when if also i use Stripe\Stripe; use Stripe\Charge; they show me another

error: No API key provided. (HINT: set your API key using "Stripe::setApiKey()". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email [email protected] if you have any questions.

i have api-key in services.php and .env every where am seposed to put api key i puted them i don't why this happens this worked later but i don't why it keeps showing me this

or should i generate new api key i don't why

Activity icon

Replied to Redirect To?

what i see you guyz are confused on my post that one i posted works but have different routes

protected function redirectTo () {
        if(Auth::user()->usertype == 'admin') 
        {
            return 'dashboard';
        } 
        elseif(Auth::user()->usertype == 'vendor')
        {
            return 'vendor-dashboard';
        }
        elseif(view('post.graphics'))
        {
            return 'graphics';
        }
        else
        {
            return 'post';
        }
    }

when i login it redirect me to graphics without going to the one i was going on

for example: it takes the first route without checking which am on

Activity icon

Replied to Redirect To?

@jlrdw me i just want to click to the link that redirects me to the page i want to on if it requires me login then i login and redirect me to the page i wanted to go on

Activity icon

Replied to Redirect To?

@jlrdw how to use authenticated method in the trait

Activity icon

Replied to Stripe How To Get Amount?

@bobbybouwmann i don't know why they are showing this error: The Stripe API key is not defined!

am using Cartalyst\Stripe\Stripe;

Activity icon

Replied to Redirect To?

what can i use to make it work, which method show me please

Activity icon

Started a new Conversation Stripe How To Get Amount?

i just want to get amount from database directly to stripe dashboard

$stripe = new Stripe(env('STRIPE_SECRETE'));
        $charge = $stripe->charges()->create([
	   // 'amount' => Graphic::get('amount'), i tried this but it does'nt work
            'amount' => 1000,
            'currency' => 'rwf',
            'description' => 'Your work done info',
            'source' => $request->get('stripeToken'),
            'receipt_email' => $request->get('email'),
            // Verify your integration in this guide by including this parameter
            'metadata' => [
                'order_id' => 3243,  
            ],
        ]);
Apr
21
1 month ago
Activity icon

Awarded Best Reply on Property [name] Does Not Exist On This Collection Instance.

the answer was this i changed the $file variabe to this $graphics

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');

	// here is where i changed

        $graphics = Graphic::create([
            'name' => $request->name,
            'time' => $request->time,
            'description' => $request->description,
            'file_title' => $upload->getClientOriginalName(),
            'file' => $path,
            'user_id' => Auth::user()->id
        ]);
            return view('guavahire.graphics.payment', ['graphics' => $graphics]);
        }
        
    }
Activity icon

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

@snapey so show me what can i change up to be clear

where will i put it and why i redirect like that because i want create a post and go to payment there no other way my user can know that page of payment me too i think about it and thanks for your advice big salut

Activity icon

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

the answer was this i changed the $file variabe to this $graphics

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');

	// here is where i changed

        $graphics = Graphic::create([
            'name' => $request->name,
            'time' => $request->time,
            'description' => $request->description,
            'file_title' => $upload->getClientOriginalName(),
            'file' => $path,
            'user_id' => Auth::user()->id
        ]);
            return view('guavahire.graphics.payment', ['graphics' => $graphics]);
        }
        
    }
Activity icon

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

thank yeah all for your help i final found the solution

gracias amigo