ouhare

ouhare

Member Since 3 Years Ago

Perpignan, France

Experience Points 96,070
Experience Level 20

3,930 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 832
Lessons
Completed
Best Reply Awards 20
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

20 Mar
1 day ago

ouhare left a reply on JS Function In Laravel For Vue2?

@b

bind your function to the window object.

window.getMinMax= function (.....)
18 Mar
3 days ago

ouhare left a reply on Chat System - Laravel , Redis And Socket.io

@talhaatsix

If you use PresenceChannel, an event will be emit when the user close his browser or logout. Then, you can listen to it with Echo, and do your stuff.

https://laravel.com/docs/5.8/broadcasting#presence-channels

ouhare left a reply on Chat System - Laravel , Redis And Socket.io

@talhaatsix this flow is pretty okay.

to restrict messages sent to user, you have to use PresenceChannel (very useful for a chat system)

15 Mar
6 days ago

ouhare left a reply on Installing Vue Datatables Unable To Find Component

Did you run php artisan vendor:publish --tag=enso-assets ?

13 Mar
1 week ago
07 Mar
2 weeks ago

ouhare left a reply on Keep Current User Logged In When Creating A New User In Admin

@roerjo

My bad, I pick this trait in a old laravel project.

and yes, just follow the @roerjo solution, much cleaner.

ouhare left a reply on Keep Current User Logged In When Creating A New User In Admin

The RegisterController use a trait called RegistersUsers. In order to modify the auto login of the newly created user, you have to provide your own RegistersUserstrait.

Here the code of RegistersUsers trait :

<?php

namespace Illuminate\Foundation\Auth;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

trait RegistersUsers
{
    use RedirectsUsers;

    public function getRegister()
    {
        return view('auth.register');
    }

    public function postRegister(Request $request)
    {
        $validator = $this->validator($request->all());

        if ($validator->fails()) {
            $this->throwValidationException(
                $request, $validator
            );
        }

        Auth::login($this->create($request->all()));

        return redirect($this->redirectPath());
    }
}

Just copy & paste it to your own trait file and don't forget to remove the line : Auth::login($this->create($request->all()));

Then use your trait in RegisterController !

05 Mar
2 weeks ago

ouhare left a reply on Laravel Not Executing Queries With 'DATEDIFF'

@bekaskaki

I think you don't need the $tgl variable. STR_TO_DATE needs a placeholder for the second parameter, not a formatted date.

Just run:

$data = DB::select('SELECT * ,IF(DATEDIFF(STR_TO_DATE(tgl_selesai, "%Y-%m-%d")), CURDATE())<=0,"Berakhir","Masih Berjalan") status FROM data_kerjasama');

ouhare left a reply on Laravel Not Executing Queries With 'DATEDIFF'

@bekaskaki try this

$data = DB::select("SELECT * ,IF(DATEDIFF(STR_TO_DATE(tgl_selesai, '$tgl')), CURDATE())<=0,'Berakhir','Masih Berjalan') status FROM data_kerjasama");

notice the simple quote to double quote

ouhare left a reply on Laravel 5.0.13 Not Passing Trough Update Function

@candyy ok, nice. So, you can mark this thread as solved.

04 Mar
2 weeks ago

ouhare left a reply on Laravel 5.0.13 Not Passing Trough Update Function

@candyy can you post the categories routes from routes/web.php ?

ouhare left a reply on Laravel 5.0.13 Not Passing Trough Update Function

@candyy Did you check Requests\UpdatePageRequest.php ?

it seems that you use the same Request class for a product and a category.

01 Mar
2 weeks ago

ouhare left a reply on Redirecting To A Show Controller Method After A Put Controller Method.

@lukio_3 so you have to to perform your redirection on the front-end.

ouhare left a reply on Redirecting To A Show Controller Method After A Put Controller Method.

Do you use an Ajax Request to update the record ?

29 Jan
1 month ago

ouhare left a reply on Still Unauthorized Using CreateFreshApiToken Middleware

@BILLRIESS - Sure !

routes/api.php

<?php

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

app\Http\Kernel.php

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    protected $middleware = [
        \App\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \App\Http\Middleware\TrustProxies::class,
    ];

    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
    ];

    protected $middlewarePriority = [
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\Authenticate::class,
        \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
        \Illuminate\Auth\Middleware\Authorize::class,
    ];
}

ouhare left a reply on Still Unauthorized Using CreateFreshApiToken Middleware

@BILLRIESS - Yes it does and it returns 401 { "message": "Unauthorized" }.

It's working if I remove the middleware.

27 Jan
1 month ago

ouhare started a new conversation Still Unauthorized Using CreateFreshApiToken Middleware

Using Laravel 5.7 with Laravel Passport 7.0.5 and CreateFreshApiToken middleware and using vuejs & axios with default javascript scaffold (header X-CSRF-TOKEN and X-Requested-With).

My users are logged using session driver (Auth::attempt). I got the laravel_token attached on outgoing responses.

When I use axios to call '/api/user', the laravel_token cookie is correctly send (with laravel_session and XSRF-TOKEN) but I still have a 401 - Unauthorized response...

Do I do something wrong ?

03 Oct
5 months ago

ouhare left a reply on Add To Cart Qty Not Working,

@tehseen What happen if your $item already exists in your $this->items array ? You can set $qtywith any number you want, it will pick up the quantity of $this->items[$id].... I guess

ouhare left a reply on Add To Cart Qty Not Working,

when i pass third parameter $qty in my add function

Where is your third parameter? public function add($item, $id)

01 Oct
5 months ago

ouhare left a reply on Ajax Not Sending Data To Controller

@rory

You are using inside your form

<input type="hidden" name="_token" id="token" value="{{ csrf_token() }}">

You can replace it with {{ csrf_field() }}.

then, you can try this instead:

var formdata =  $('#sistrixKw').serialize();
$.post('/sistrix', formdata, function (response) {
    console.log(response)
});

ouhare left a reply on How To Get Value/Data In Dropdown Options, That I Have Inserted Into Table...?

did you pass your $allbus variable to your view?

ouhare left a reply on Ajax Not Sending Data To Controller

data: { 'formdata' : formdata, "_token": $('#token').val() }

Try this (without the quote)

28 Sep
5 months ago

ouhare left a reply on Can You Explain This Code

$role is the "parameter" passed through 'Role:0'. In this case, it's 0.

ouhare left a reply on Policy Is Not Registering

Try to use the Gate facade instead.

use Illuminate\Support\Facades\Gate;

Gate::define(...)

You don't have to set it within boot method.

ouhare left a reply on How To Use Show($id) With Foreign Key Relationship?

$engagement = Engagement::with('client')->find($id);

ouhare left a reply on Can You Explain This Code

if ($request->user()->role < $role) {
    return abort(404);
}

You've got your response !

ouhare left a reply on Policy Is Not Registering

Policies have to be registered in AuthServiceProviderclass

ouhare left a reply on Can You Explain This Code

You should check your app/Http/Kernel.php file and your app/Http/Middleware folder.

ouhare left a reply on Url Rewriting Not Working Outside Laravel For Mix

Did you try to add processCssUrls: false to your mix options?

ouhare left a reply on Many To Many Relationship

Maybe you can use an additionnal pivot column to specify the "quantity of relations" ?

module_id | component_id | quantity
      1              |             1               |        3
22 Sep
5 months ago

ouhare left a reply on Anybody Using Vuetify?

You should really check Quasar Framework, the best UI toolkit framework imo.

https://quasar-framework.org/

17 Sep
6 months ago

ouhare left a reply on Load Js Dependecy In My Bootstrap.js

No, bootstrap.js is not loaded by default. You have to require it in your app.js file !

07 Sep
6 months ago

ouhare left a reply on Replacing A Large Array

Did you try to do something like:

const newArray = await apiCall()
this.myData = [ ...newArray ]

?

23 Aug
6 months ago

ouhare left a reply on Lazy Loading A Relationship Works, But Eager Loading Fails

Is your BaseReturn class extending Illuminate\Database\Eloquent\Model ?

12 Jul
8 months ago

ouhare left a reply on Access Eloquent Relationship In Vue.js

First of all, your 'items' data should be an array :)

data () {
    return {
        items: []
    }
}
27 Jun
8 months ago

ouhare left a reply on Pass Data From Laravel To [email protected]

Can you post your 'Project_model' class ?

21 May
10 months ago

ouhare left a reply on Not Redirecting After Submit

I guess you have to redirect the user with javascript.

Try to listen for any 'success' event from dropzonejs, then redirect the user.

myDropzone.on('success', () => {
  window.location.href = "anyUrl"
})
17 May
10 months ago

ouhare left a reply on Search The Database But Does Not Pass The Value

@foreach ($cliente as $id => $cli)
    <option value="{{ $id }}">{{ $cli }}</option>
@endforeach
14 May
10 months ago

ouhare left a reply on How To Hide Id From URL

I guess you can use php session.

ouhare left a reply on Disable Reactivity

Try to 'clone' data using lodash or Object.assign

ouhare left a reply on Invalid Argument Supplied For Foreach()

Did you try to dump $request->input('hobbies')?

06 Apr
11 months ago

ouhare left a reply on How To Identify REST API Client On API-server Side?

I need to know which of the API clients is making the request

Do you talk about authenticated user ? If so, you should try auth()->user()

ouhare left a reply on Search In A Multidimensional Array

I will use:

function searchDataType($type, $arr) {
    $index = array_search($type, array_column($arr, 'data_type'));
    return $index > -1 ? $arr[$index] : null;
}

$found = searchDataType('USER_ID', $data);

var_dump($found);
// ['data_type' => 'USER_ID', 'data' => '2']
03 Apr
11 months ago

ouhare left a reply on Vue Not Updating On First Element Array

Hello, can you post the 'isSelected' method code ?

04 Mar
1 year ago

ouhare left a reply on Sqlite 3 And HTML Checkbox Trouble

Can you post the result of:

dd($request->all());
14 Feb
1 year ago

ouhare left a reply on Laravel Passport Not Respecting Oauth Refresh_token?

From RFC 6749, on a refresh_token request:

...The authorization server MAY issue a new refresh token, in which case the client MUST discard the old refresh token and replace it with the new refresh token.  The authorization server MAY revoke the old refresh token after issuing a new refresh token to the client.  If a new refresh token is issued, the refresh token scope MUST be identical to that of the refresh token included by the client in the request....