visualight

visualight

Member Since 4 Years Ago

Experience Points 1,390
Experience Level 1

3,610 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 0
Lessons
Completed
Best Reply Awards 0
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.

29 Oct
2 years ago

visualight started a new conversation SortBy Price With Limit And Offset On Multiple Tables

Hello everybody,

I tear my hair for a few days to try to find a solution to my problem. I have 3 tables through which I want to sort the results by price (desc or asc) to display on a page.

The problem I think is at near the "limit and offset." I think in fact that "Eloquent" does not understand that he must get the elements of my table with priority the ASC or DESC price. Indeed, at page 0 (limit 20, offset 0), all prices are properly sorted, but when I load another page, I found some price to $ 1, while the last record of the first page (limit 20, offset 0 is $ 3).

How to keep the system "limit + offset" while having the results sorted properly?

Here is part of my code ... Thank you


if($type == '')
            {
                $albumsOrder1 = [
                    'type' => 'album_price',
                    'value' => 'asc'
                ];

                $objectsOrder1 = [
                    'type' => 'object_price',
                    'value' => 'asc'
                ];

                $contactsOrder1 = [
                    'type' => 'contact_price',
                    'value' => 'asc'
                ];
            }
$albums1 = AlbumUser::with(array('pictures' => function($q){
                $q->where('status', 2);
                $q->orderBy('order', 'asc');
            }))->with(array('users' => function($u){
                $u->with('commission');
            }))->where(function($r){
                $r->where('status', 2);
                $r->where('active', 1);
                $r->where('album_promo', 0);
            })->orderBy($albumsOrder1['type'], $albumsOrder1['value'])->orderBy('created_at', 'desc')->limit($limit)->offset($start)->get(array('*', 'album_price as price'));

            $objects1 = ObjectUser::with(array('users' => function($u){
                $u->with('commission');
            }))->where(function($q){
                $q->where('active', 1);
                $q->where('status', 2);
                $q->where('object_promo', 0);
            })->where(function($r){
                $r->where('object_quantity', -1);
                $r->orWhere('object_quantity', '>', 0);
            })->with('canvas')->orderBy($objectsOrder1['type'], $objectsOrder1['value'])->orderBy('created_at', 'desc')->limit($limit)->offset($start)->get(array('*', 'object_price as price'));

            $contacts1 = ContactUser::with(array('users' => function($u){
                $u->with('commission');
            }))->where(function($q){
                $q->where('status', 2);
                $q->where('active', 1);
                $q->where('contact_promo', 0);
            })->where(function($r){
                $r->where('contact_quantity', -1);
                $r->orWhere('contact_quantity', '>', 0);
            })->with('canvas')->orderBy($contactsOrder1['type'], $contactsOrder1['value'])->orderBy('created_at', 'desc')->limit($limit)->offset($start)->get(array('*', 'contact_price as price'));

$collection1 = $albums1->merge($objects1);
$data = $collection1->merge($contacts1);

if($filter == 'priceDesc')
        {
            $data = $data->sortByDesc('price');
            $data = $data->values()->all();
        }
        elseif($filter == 'priceAsc')
        {
            $data = $data->sortBy('price');
            $data = $data->values()->all();
        }
      dd($data);
06 Jul
3 years ago

visualight started a new conversation View Cache Must Always Be Cleared Manually

Hello,

I use Laravel 5.1 (last version) since few week, if a make a change to a view file, i must always do the command : php artisan view:clear otherwise the changes on the "view" blade files do not work. Can you help me ?

Here is the config I made on the server :

sudo chmod -R gu+w storage sudo chmod -R gu+w bootstrap/cache sudo chown -R ubuntu.www-data /var/www/mywebsite.com

Thank you

18 Jun
3 years ago

visualight left a reply on Laravel Session : Check If Not Exist

Yes of course i use sublimetext and o forgot to init Session in my controller (but i never get errors).

visualight started a new conversation Laravel Session : Check If Not Exist

Hello,

I try to detremine if a session in laravel not exist. I do the following request but it doesn't work :

''' if(!Session::has('location')){ ... } '''

How i can check if a laravel session (session::put) is not set ? Thank you

12 Jun
3 years ago

visualight left a reply on Admin Panel : Access Member Profile (view As)

I found a solution :

In the user table, create à field : token and populate with a random string every time the administrator logged in. Then in the admin panel when you click on a "view profile" link for a specific user, the administrator token is set in session. After that, i use Auth::loginUsingId($id); to connect me to a user account.

To return to the admin panel without reintroducing credentials, i placed a link in the user dropdown menu (back to admin) witch check if the session is set, retrieve the token and check if a user in the database has this token. After, i process simply by Auth::loginUsingId($admin_id); again.

Hope this help someone :-)

10 Jun
3 years ago

visualight left a reply on How To Write This Associative Query In Laravel 5.2 ?

public function index()
    {
        $user=\Auth::user();
        $users = User::with('articles', function($q){
        $q->with('category');
    })->get();
    
        return view('index',  compact('users'));
    //$users->firstname (get username)
    //$users->articles->title (get the title)
    //$users->articles->category->name (get the name or slug of the category)
    }

You must make a function articles with relationship belongsToMany in the User Model and a function category with relationship hasOne in the Article Model.

Hope it will help you :-)

visualight started a new conversation Admin Panel : Access Member Profile (view As)

Hello, I created a website where users can subscribe an account. My authentication system is based on roles and permissions. Currently, as an administrator, if I want to access a user account (in moderation ...), I click on a link from my administration panel and I can access the account through my userlevel who is a admin. I would like to know if there is another method to access a user account while maintaining my connection active to the admin panel. Indeed, I would like to know if Laravel can manage simultaneous mutiples autentifications without losing the main administrator connection ? (I do no want to reconnect me to the admin panel after each access to the page of a member).

Thank you

20 Dec
3 years ago

visualight started a new conversation Translation Route/view Not Working

Hello,

I try to create a multi language website with laravel 5.2. To translate my files, i use the code in the route :

Route::get('/{locale}', [ 'as' => 'home', 'uses' => 'homeController@index' ], function($locale){ App::setLocale($locale); });

For the tests, I added a line : 'hello' => 'BONJOUR' in a file located in the lang/fr directory.

In a view, when i call : {{trans('auth.hello')}}, i get not the translation but the words : "auth.hello".

How i can make a working translation ? (mywebsite.com/en, mywebsite/fr, ... )??

Thank you

09 Jun
4 years ago

visualight started a new conversation Composer Global Require "laravel/installer=~1.1"

Hello,

To create a new project with laravel I use the command : laravel new ... Laravel 5.1 LTS released i want to upgrade the "root" installation of laravel using : composer global require "laravel/installer=~1.1" but this command does not upgrade laravel.

I dont want to update the existing laravel files of a project. I want to upgrade the laravel installer 5.0 to 5.1.

Here is the output i receive when i try to update the installer :

Changed current directory to /Users/xxx/.composer ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files

Thank your for your help

27 May
4 years ago

visualight started a new conversation L5 API For Mobile Devices + Facebook Connect

Hello,

I have to create an API for mobile devices. For this I use Laravel 5. Users of this API must register and authenticate via Facebook Connect.

I'm having a problem understanding the functioning and the creation of this API.

  1. Is Facebook will send me a token I have to register my User table?

  2. Do I have to use JWT Token?

  3. How to put it all together?

I admit, I'm confused ... this is my first API Does anyone can explain to me the working principle with token?

thank you

25 May
4 years ago

visualight left a reply on L5 Authentification : Show Guest Home Page

@bashy Ok error : Guest middelware is called ... Ok thank you

visualight left a reply on L5 Authentification : Show Guest Home Page

@bashy The HomeController have the auth middleware but the WelcomeController have no middleware

visualight left a reply on L5 Authentification : Show Guest Home Page

@bobbybouwmann My route is already created.

Route::get('/', [
    'as'=>'homePage',
    'uses' =>'WelcomeController@index'
]);

If i logout, i can acces to my route if i am logged in i cannot

visualight left a reply on L5 Authentification : Show Guest Home Page

@bobbybouwmann thank you, but i get a 404 error if i am logged in and i try to access to the base url " / " (homepage). If i disconnect, i can accès with success to my homepage.

visualight started a new conversation L5 Authentification : Show Guest Home Page

Hello,

I use the buit in authentification for Laravel 5. When i log in, i am redirected to the mysite.com/home (Homecontroller@index). The problem : i want to access to the homepage : mysite.com (welcomeController@index) but it doesn't work.

How i can acces to my homepage when i am logged in ?

Thank You

22 May
4 years ago

visualight left a reply on Admin Panel : Login As User

@bart D'OH ! Thank you :-)

visualight left a reply on Admin Panel : Login As User

@frezno Simply, if a user encounter an error or mistake (or not understand) something, i can place me in the right context to see and help the user to resolve the problem.

I do not store not crypted password in the database. Actually to log me as a user i use : Auth::loginUsingId($id). But such as i said in my previous post, when i connect me as a user, i am disconnected from the admin panel. So i am searching for a secure solution that keep me logged as admin and in the same time i can access to users page simply by a click on his username in the user management console of my admin panel.

visualight started a new conversation Admin Panel : Login As User

Hello,

I have a admin panel with a list of users. When i click on the username of a user, i need to open his own page (with his information).

Actually, i loggin as user and i can perform necessary operations but everytime i loggin as a user i am disconnected from my admin panel.

Actually i use the part of code to log me in as user. Do you know a other solution to keep my admin panel active and open Users pages as the user see it ?

Thank You

public function connectAsUser($id)
{
        if (Auth::loginUsingId($id))
        {
            return redirect()->intended('/home');
        }
        else
        {
            return 'ERROR';
        }
}
20 May
4 years ago

visualight left a reply on Laravel 5 Redirect To Different Controller After Authentification

@dfaux ... postRegister method ? Are you sure ? Why not postLogin method ?

visualight started a new conversation Laravel 5 Redirect To Different Controller After Authentification

Hello,

I made a table with roles and permissions for authenticated users. I want to redirect logged in users and admin to a different controller each.

For example : Admin is redirected to AdminController@index and standard users are redirected to usersController@index.

Actually each users and admin are redirected to homeController@index after login and this is not a right way for me.

To ByPass this problem actually i do this but i foud this is not a right beautiful method. Can you tell me how i can redirect users to UsersController and admin to AdminController after login ?

public function index()
{
        $user = Auth::user();

        if ($user->is('user'))
        {
            if(!$user->checkProfile())
            {
                return redirect('profile');
            }
            else
            {
                return view('backend.home', ['page'=>'dashboard', 'action'=>'dashboard']);
            }
        }
        elseif ($user->is('admin'))
        {
            return view('backend.admin.dashboard', ['page'=>'dashboard', 'action'=>'dashboard']);
        }
        else
        {
            return view('errors.503');
        }
}
17 May
4 years ago

visualight left a reply on Amazon S3 Upload ACL

Ok, the only way i found is Granting Read-Only Permission to an Anonymous User. See : https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html

visualight left a reply on Amazon S3 Upload ACL

@vipin93 Not working :-(

visualight left a reply on Amazon S3 Upload ACL

@vipin93 It change nothing i get always an error : AccessDenied after upload (when i try to view it by clicking on the link provided by amazon). If i manually set the permission on S3 panel (make public) it work.

Here is my config (filesystems.php)

's3' => [ 'driver' => 's3', 'key' => '', 'secret' => '', 'region' => 'eu-central-1', 'bucket' => '******', 'visibility' => 'public' ],

visualight left a reply on Amazon S3 Upload ACL

@vipin93 I had already made this operation on the bucket but it does not work For my key and secret i generated a user on the IAM interface on amazon. In laravel i use these credential but all file uploaded is with the permission (ME)

ME : List - Upload/Delete - View Permissions - Edit Permissions EVERYONE : View Permissions AUTH USER : Upload/Delete - View Permissions

visualight started a new conversation Amazon S3 Upload ACL

Hello,

I try to upload a file to Amazon S3. If i do this, it work fine but the file is not accessible to public-read ACL.

Storage::disk('s3')->put($fileName, File::get($file))

Next, i try this but it doesn't work.

Storage::disk('s3')->put($fileName, File::get($file), 'public')

Can someone help me ?

Thank You

15 May
4 years ago

visualight started a new conversation Redirect After Authentification

Hello,

I use laravel 5 with buit in authentification system. I try to redirect to a specific url after authentification.$ The url must contain the username (ex: http//laravel.dev/user/visualight)

Here is how i do (but it doesn't work) :

In AuthController.php : protected $redirectTo = '/user/'.Auth::user()->username;

I get these error :

FatalErrorException in AuthController.php line 21: syntax error, unexpected '(', expecting ',' or ';'

PHPStorm give me these error : expression is not allowed as field default value

How i can redirect a user to a specific url (that url must contain his username) after login ?

Thank you

06 May
4 years ago

visualight left a reply on Set Meta Title And Description In Authentification

Thank you for your reply. I understand how pass datas from a controllers to views but in this case (laravel 5), the authentification class (with all method) is inside the illuminate directory so if i modify the class (AuthenticatesAndRegistersUsers.php) which is located to vendor/laravel/framework/illuminate/ … all my modifications will be overwrited if i do an update of laravel with composer.

So can you explain me how i can apply a different meta to each method for this case ?

Thank you

visualight started a new conversation Set Meta Title And Description In Authentification

Hello,

Just a question, how i can pass meta title dynamically from new authentification system to blade template ?

I need to modify : AuthenticatesAndRegistersUsers class or there is a another solution ? Thanks