bionary

bionary

Member Since 2 Years Ago

Experience Points 9,320
Experience Level 2

680 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 85
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.

14 Sep
1 day ago

bionary left a reply on Making Sense Of Password Reset

Thank you @jlrdw and @snapey. This was helpful.

btw, the biggest problem was a little setting in Atom IDE (exclude VCS Ignored Paths) which was preventing my searches from traversing into the vendor directory.

I won't even pretend to understand every part but I can generally see what's happening.

I spent over an hour just trying to figure out these lines:

public function sendResetLinkEmail(Request $request)
{
    $this->validateEmail($request);

    // We will send the password reset link to this user. Once we have attempted
    // to send the link, we will examine the response then see the message we
    // need to show to the user. Finally, we'll send out a proper response.
    $response = $this->broker()->sendResetLink(
        $request->only('email')
    );

    return $response == Password::RESET_LINK_SENT
                ? $this->sendResetLinkResponse($request, $response)
                : $this->sendResetLinkFailedResponse($request, $response);
}

It's like a labyrinth of code. Each time I follow where it's going it leads me somewhere else. It's very tricky because it's super minimal but resides in so many places. It's well structured but damn it's hard to follow!

bionary left a reply on Making Sense Of Password Reset

I figured it was something like that but how come my search for "showLinkRequestForm" comes up empty? Doesn't this method (trait?) have to exist somewhere?

bionary started a new conversation Making Sense Of Password Reset

I'm working with my laravel 5.7. I'm baffled by the login/auth/password logic. I'm trying to follow the route of the code and can't make any sense of it.

For instance:

running> php artisan route:list I can see this:

    password/reset | ... Auth\[email protected]

So I checkout the class: ForgotPasswordController and there is no method: showLinkRequestForm()

So I'm thinking that maybe this is a "behind the scenes" Laravel treat so I'm thinking it's inhereted from somewhere, so..

I head up to: Find>Find in Project (I'm using Atom IDE)

and search for "showLinkRequestForm"

... no results

What the heck is going on here?

The http://127.0.0.1:8000/password/reset page certainly does load, but I can't follow any of the logic.

Need some help here please.

11 Sep
4 days ago

bionary left a reply on Pass Model By Reference?

I appologize, the hipster-markdown is not working. I indented for the code blocks and it is not working. Very Annoying.

And I can't find anyplace to revise my post.

bionary started a new conversation Pass Model By Reference?

I'm getting an error:

Indirect modification of overloaded property App\Task::$errors has no effect

I'm pretty sure this is one of those "pass by value" instead of "by reference" issues.

I have a model: Task $task Which I'm passing to another class

The $task contains an attribute: $task->errors;

Which I continually add error messages to as an array. I run into trouble when inside a class and doing this: public function getBrandsList(Task $task){ $task[] = 'Another error.'; }

I would have thought that the following would have rectified this but it doesn't: public function getBrandsList(Task &$task){ ...

The following works but it sure looks and feels sloppy: public function getBrandsList(Task $task){ $task->errors[] = array_merge($task->errors, ['Another error.']); }

Is there is cleaner way to do this? Is there a way to pass my Task $task model by reference?

Thanks

13 Jan
8 months ago

bionary left a reply on Making Form Dropdown: DRY And Validate?

Simply wow, I am grateful for your examples and explanation Snapey! You have nudged me in a direction that has actually streamlined my code. Now that I know what was possible I went back and read some of the docs and watched some of the tuts as well.

For more information checkout:

https://laravel.com/docs/5.7/configuration

https://laracasts.com/series/laravel-from-scratch-2018/episodes/23 (beginning ~ 8:30 )

The problem is I watch all of these things but forget about them or don't know where to look. But your response was incredibly helpful.

I ended up making a file: config/myappname.php

And in there I have a multi dimensional array containing all lists, everything.

I love how laravel can cache the configs into one file!

php artisan config:cache

so cool.

Thanks a bunch!

12 Jan
8 months ago

bionary left a reply on Making Form Dropdown: DRY And Validate?

@SNAPEY - Hey thanks, this is a good suggestion but I'm a bit unclear on a few things you mentioned.

After reading the api/doc it looks like I would create the lists of things via a valuestore method. So I would need an admin script of some sort to build out the json file, right? Is this what you mean by "seeder"?

I'm not sure what you mean by migration? I think of database when I hear that term.

I can't see why committing the json file would be problematic but I'm probably missing something. The only this in this json file would be lists of things such as: states, sizes, colors, etc... Things only I add in and rarely change. Couldn't I just run my seeder script after I make a change push the json to production?

Thanks.

bionary started a new conversation Making Form Dropdown: DRY And Validate?

What is a good way to architect form dropdowns so that I don't have to change datasets in multiple places and can also easily validate the form data server-side.

It almost feels like I should be making a helper function/array or something in laravel somewhere. And then looping through that array in blade, but also using this helper to validate the data.

An example use case would be a list of states (NY,NJ,CA,...) or a list of colors (red,blue,yellow,...). If the data lives somewhere in laravel, then items can easily be added...but where would this data live and what's a good best-practice?

Any thoughts?

Thank you

16 Oct
10 months ago

bionary left a reply on Architecture For Queueing Tasks?

@Mithrandir & @D9705996 This is all good advice and points me in the right direction. @Mithrandir - thank you for your overview of each component/class.

10 Oct
11 months ago

bionary started a new conversation Architecture For Queueing Tasks?

I've been doing some scraping of web pages to collect data (using Goutte) and realizing that it makes sense to put all these requests into some kind of queue and have them executed slowly over time.

I'm thinking I would: 1)place requests in database 2)work through them using Laravel's: Illuminate\Console\Scheduling\Schedule;

My specialty seems to be reinventing wheels so I don't won't to build some functionality if it already exists.

What would be a good way to go about this in Laravel?

I'm a bit confused between Laravel's Queues, Jobs, and Task Scheduling... are these helpful for what I'm trying to do?

06 Oct
11 months ago

bionary left a reply on Foreign Character Insertion And Retrieval

Yes sir, the entity is saving in the db. As in &-e-a-c-u-t-e-; without the hyphens. I took a look at the page source and it is the character, not the entity. btw I'm using Goutte.

I just ran the data through html_entity_decode() and that of course fixed it. There must be some strange conversion somewhere along the way, perhaps with Goutte?

Either way, thank you for your help; the data is being saved normally as a foreign character now.

bionary started a new conversation Foreign Character Insertion And Retrieval

I've scraped some webpages to generate a list of words and I noticed that a foreign character botches up things.

The offending character is: é ("e" with slash over it)

It saves into the database as [b]é[/b] as I can plainly see this in phpmyadmin. When I render the view it also displays as [b]é[/b]

I'm using a standard laravel 5.7 installation and I've checked my table which is set to utf8mb4_unicode_ci

How should I be handling this? Shouldn't the foreign character be stored as is in the db and not the html entity? Not sure what to do thanks.

06 Feb
2 years ago

bionary left a reply on Provide Error Messages With Custom AUTH Middleware V5.3

So I've been trying different things and still use some advice. I figured out that I can use the Validator class to validate form data but Im not sure what's the best way to pass back a generic message about a failed login attempt.

Maybe I'm barking up the wrong tree here... but this is what I've got now in my custom auth middleware: the validation logic is obviously not something I would use... just testing with it.

namespace App\Http\Middleware;

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

class TeacherAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        if (Auth::attempt(['first_name' => $request->first_name, 'last_name'=>$request->last_name, 'password' => $request->password])) {
            // Authentication passed...
            return redirect()->intended('dashboard');
        }
        $validation = \Validator::make($request->all(), [
            'first_name' => 'required|max:1',
            'last_name' => 'required|max:10',
            'password' => 'required|min:6|confirmed',
        ]);
        return back()->withInput()->withErrors($validation);
    }
}

I would like to pass back a generic message about the failed login but everything I'm seeing in the docs is really specific about each form input.

What's the laravel way to pass back and handle a failed login message?

Any ideas?

31 Jan
2 years ago

bionary started a new conversation Provide Error Messages With Custom AUTH Middleware V5.3

I am logging in users with a table called 'teacher' and am using first_name, last_name, password to handle the authorization. I am using middleware to do this and whether it's all set up correctly is a mystery to me but it does indeed seem to work.

My problem right now is there is no error reporting back to the user when the auth fails.

I placed {{ var_dump($errors) }} in my view and it is always empty on failed login attempts.

{{ var_dump($errors) }}  /// yields:

object(Illuminate\Support\ViewErrorBag)[173]
  protected 'bags' => 
    array (size=0)
      empty
//route
Auth::routes();
Route::post('login')->middleware('auth.teacher');

Route::group(['middleware'=>['auth']], function(){
    Route::get('/', function () {
        return view('dashboard');
    });
    Route::get('/dashboard', function () {
        return view('dashboard');
    });
//my custom auth middleware
namespace App\Http\Middleware;

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

class TeacherAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        if (Auth::attempt(['first_name' => $request->first_name, 'last_name'=>$request->last_name, 'password' => $request->password])) {
            // Authentication passed...
            return redirect()->intended('dashboard');
        }
        return back()->withInput();
    }
}

Doesn't anyone know how to report out the login errors? (And if I'm doing this the wrong way please advise as well )

Thanks!

29 Jan
2 years ago

bionary left a reply on Customizing Auth Laravel 5.3

All I'm trying to do is log in a teacher using form inputs: first_name, last_name, password. So use middleware not policies? Okay.

I have some knowledge of middleware but I'm not sure how to do this to log a teacher in. I know that I can protect all routes by wrapping them in a group that applies the middleware.

So far I've tried customizing existing loginController, here's what I did after reading the L5.3 manual ( https://laravel.com/docs/5.3/authentication#authenticating-users) :

\\LoginController.php
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);
    }
    public function authenticate(){
      exit('test');
    }
}

Is this what you mean? or...

Next I tried creating my own middleware:

//Middleware/TeacherAuthenticated.php
namespace App\Http\Middleware;

use Closure;

class TeacherAuthenticated
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        dd($request->all());
        return $next($request);
    }
}

registered with the kernel

//kernel
    protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'auth.teacher' => \App\Http\Middleware\TeacherAuthenticated::class,
    ];

And I manually applied the middleware:

//routes/web.php
Auth::routes();
Route::post('login')->middleware('auth.teacher');

Route::group(['middleware'=>['auth']], function(){
    Route::get('/dashboard', function () {
        return view('dashboard');
    });
    Route::get('/students', function () {
        return view('students');
    });
});

Is this the preferred method or is altering the LoginController the way to go?

bionary left a reply on Customizing Auth Laravel 5.3

I notice you have 'extends' twice

Doh, I should have seen that one. (I'm switch my IDE to Atom and it highlights things different from what I'm used to)

That solves my first problem @ejdelmonico , thanks!

So I spent the last 2 hours reading about and experimenting with policies. I made/registered one. I ran:

php artisan make:policy TeacherLoginPolicy

I'm still unsure about how to actually apply the policy during the login phase though. The docs talk extensively about CRUD, but I'm trying to AUTH so I'm confused.

Things currently work fine logging in using email/password. BUT...

I want to use [first_name, last_name, password] for my input fields

Here's what I have so far:

//TeacherLoginPolicy.php
namespace App\Policies;

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

class TeacherLoginPolicy
{
    use HandlesAuthorization;

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

I registered the policy here:

//AuthServiceProvider.php
namespace App\Providers;

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

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
        Teacher::class => TeacherLoginPolicy::class,
    ];

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

        //
    }
}

Not sure where to go from here?

28 Jan
2 years ago

bionary started a new conversation Customizing Auth Laravel 5.3

Greetings,

I'm trying to customize the users that will be logging into my Laravel application. I'm having some trouble:

  1. Using custom fields
  2. Extending Authenticatable
  3. Understanding what's going on (there's so much "behind the scenes" to quote Jeffrey)

Q1:

The table of users I'm trying to authorize is called:teacher and its model looks like this:

//Teacher.php
namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Teacher extends extends Authenticatable{
  use Notifiable;
  protected $table='teacher';
  protected $fillable = [
      'tid','school_id','title','first_name','last_name','email', 'password','term_id','admin',
  ];
  public $timestamps=false;
  protected $hidden = [
      'password', 'remember_token',
  ];
}

I'm pretty sure this is not quite right because running this in tinker errors:

$teacher = new App\Teacher;

//PHP error:  syntax error, unexpected 'extends' (T_EXTENDS), expecting identifier (T_STRING) or namespace (T_NAMESPACE) or \\ (T_NS_SEPARATOR)

So how do I extend Authenticatable and do I even need to?

curious enough I updated config/auth.php like this and it works but I would really like to Auth using Eloquent with a properly working model.

//config/auth.php
    'providers' => [
        // 'users' => [
        //     'driver' => 'eloquent',
        //     'model' => App\User::class,
        // ],

        'users' => [
            'driver' => 'database',
            'model' => App\Teacher::class, /* this does not work */
            'table' => 'teacher',
        ],

Q2:

Of course I've read the docs and watched the laracasts from scratch vid on Auth, but the examples for customizing are murky at best. The docs for L5.3 say I can customize like this:

public function username()
{
    return 'username';
}

I want to authorize based on these fields: [first_name, last_name, password] How does one do this.

Of course I've researched this on google but all the solutions are for Laravel 5.2 ie: http://stackoverflow.com/questions/36565613/laravel-how-to-take-first-name-and-last-name-from-separate-fields-and-store-th

Any guidance would be appreciated. Thanks.

bionary left a reply on A Network Error Has Caused The Media Download To Fail Part-way

Happens 100% of the time on my windows 7 machine running chrome & once in a while on my OSX chrome & safari. Once it does happens it typically happens repeatedly from there after.

I've noticed it occurs most often when fast forwarding past the buffered zone.

The reason this sucks big time is none of the videos have "notes" or "sample code" so I like many have to stop, rewind, fast-forward constantly to see what @JeffreyWay is typing because he moves at the speed of light.

27 Jan
2 years ago

bionary left a reply on Bower Versus NPM And Clean Asset Management

Perfect explanation Ian! I appreciate all your help and patience.

26 Jan
2 years ago

bionary left a reply on Bower Versus NPM And Clean Asset Management

@ianmcqueen Hi and thanks again. Sorry for being so thick but when I add:

//app.scss
@import "bootstrap";

and run gulp i get an error:

message: 'resources/assets/sass/app.scss\nError: File to import not found or unreadable: bootstrap\n

I noticed that laravel now ships with this

//app.scss
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

This seems to work which leads me back to my question of how the heck was I supposed to figure that one out on my own if they didn't include it. I see the docs you linked to and they indeed say @import "bootstrap" but nothing about that deep traversal through the directory.

And if that works which is basically compiling a directory ie:bootstrap... How come this doesn't compile down:

@import "resources/assets/css";

or this doesn't compile down either:

@import "resources/assets/css/mycss.css";

I am left with the raw import statement in my code which is no good because it points to the app dirs above public

24 Jan
2 years ago

bionary left a reply on Auth Laravel 5.2 Vs. Laravel 5.3

cool, one last thing... I noticed that artisan put this in my get.php routes:

Auth::routes();

What's up with that? I deleted it and it doesn't appear to be breaking anything.

actually on second thought... that probably is almost like an "include" in which all those login/forget password, etc... routes are included

yep, it sure must be... as i tested this a bit further.

thanks again!

bionary left a reply on Auth Laravel 5.2 Vs. Laravel 5.3

@Chrizzmeister & @Snapey I get it now. thanks to both your suggestions. Knowing that there's 3 basic ways to do it and experimenting with all 3 I have seen the light!

Man Laravel is cool.

For other noobs like me here's 2 of the 3 ways to secure some pages... you can apply the auth middleware one at a time like:

Route::get('cards', '[email protected]')->middleware('auth');
Route::get('secret', '[email protected]')->middleware('auth');

or using groups!

Route::group(['middleware'=>['auth']], function(){
  Route::get('cards', '[email protected]');
  Route::get('secret', '[email protected]');
});

I suppose I can remove the constructor that laravel provides in the HomeController.

    public function __construct()
    {
        $this->middleware('auth');
    }

** Is there any downside to this? **

bionary started a new conversation Auth Laravel 5.2 Vs. Laravel 5.3

Hey all,

During the laracasts from scratch video series @JeffreyWay uses artisan auth to auto generate some user/login stuff.

https://laracasts.com/series/laravel-5-from-scratch/episodes/13 @4:50

In the video which I think is showing Laravel 5.2 he secures his protected routes in :

Route::group(['middleware'=>['web']], function(){
   Route::auth();
   Route::get('/home', '[email protected]');
});

This seems to be completely obsolete in Laravel 5.3

By poking around and testing it seems that to block access to routes via auth I need to do this:

//routes/web.php

Auth::routes();

Route::get('/members', '[email protected]s');
Route::get('/', '[email protected]');
Route::get('cards', '[email protected]');
Route::get('cards/{card}', '[email protected]');

And it looks like I need to inject Auth into the constructor of any controller I want to prevent non-logged in access like:

//app/Http/Controllers/CardsController.php
namespace App\Http\Controllers;

use DB;
use App\Card;
use Illuminate\Http\Request;

class CardsController extends Controller{
  public function __construct(){
      $this->middleware('auth');
  }
  public function index(){
    $cards = Card::all();

    return view('cards.index', compact('cards'));
  }
}

**Is this the Laravel 5.3 way of ensuring a user is logged in before getting the route? ** (I hope I'm doing it correctly)

Thanks

bionary left a reply on Eloquent You Sly Fox (how Does It Know My Relationships)

@martinbean

That's what @JeffreyWay was talking about in the series I'm working my way through now "Laracasts from Scratch". Would my controller setup like this create eager loading rather than n+1 ?

//StudentController
public function show(Student $student){
   $student->load('notices');
    return view('students/show', compact('student'));
}

bionary left a reply on Eloquent You Sly Fox (how Does It Know My Relationships)

@martinbean yep, been reading that and https://laravel.com/docs/5.3/queries for the past couple of days. I've seen examples of accessing the model/table's property:

$flights = App\Flight::all();
foreach ($flights as $flight) {
    echo $flight->name;
}

...but no examples like mine using a blade template

I'm still amazed at how I can join queries in my template. But, I'm very new to Laravel and am really blown away. I've always thought as the view as the endpoint that is simply rendering data that's been already fetched but apparently there is some voodoo going on that informs what data (tables to join?) back up the chain.

bionary left a reply on Eloquent You Sly Fox (how Does It Know My Relationships)

@martinbean Thank you for your helpful reply! It's always nice to have somebody take the time to help someone out with simple steps/code.

I think I get it but man it's complicated. I'm not used to working with so many layers of abstraction.

Model.php has 1350 lines of code. Did you make sense of that yourself or is there documentation on this somewhere?

Can I assume what I'm doing in my code is perfectly fine?

Thank you again for not suffering from the "curse of knowledge"

cheers

bionary started a new conversation Eloquent You Sly Fox (how Does It Know My Relationships)

I can't for the life of me figure out how Laravel is able to display associated data by simply calling a variable/method in a template. It seems magical. I'm not explicitly setting up the relationship in my controller so I'm bamboozled in a pleasurable way ;P

//my route:

Route::get('/studs/{student}', '[email protected]');

//Controller

public function show(Student $student){
    return view('students/show', compact('student'));
}

//view

<h1{{ $student->first_name }} {{ $student->last_name }}</h1>
<ul>
@foreach($student->notices as $notice)
   <li>{{$notice->body}}</li>
@endforeach
</ul>

how does Laravel know and make this work: {{$notice->body}} ???

I have this method in my notice controller:

public function notices(){
  return $this->hasMany(Notice::class);  //or ('App\Notice')
}

I would have thought that I needed my controller to look like this: //Controller

public function show(Student $student){
   $student->load('notices');//but this is unnecessary
    return view('students/show', compact('student'));
}

How can laravel/Eloquent be so smart? and know of the relationship which seems so after-the-fact being in the template?

23 Jan
2 years ago

bionary left a reply on Bower Versus NPM And Clean Asset Management

@ejdelmonico Thanks for posting that code. I'm very new to gulp and a total noob with elixir so I've spent a long time going over it line by line.

So it looks like you have to manually go through npm directories and find each asset? (It's a shame there isn't a standardized way that all packages adhere to)

What's the point of copying all the npm packages to your resource directory? Does it all get combined and output into one js and one css? I'm unclear on where this is happening in the code... care to explain?

20 Jan
2 years ago

bionary left a reply on Bower Versus NPM And Clean Asset Management

I have the same question. (I can't believe nobody answered this)

bionary left a reply on NPM Not Working

excellent. thank you so much @ejdelmonico

bionary left a reply on NPM Not Working

Here's what I did:

I went to node.js website and downloaded node.js.pkg for my osx I clicky-clacked through their installer and it did it's thing.

First thing off the bat I noticed was the new install was a lower version than the one I posted above (maybe I had a unstable release?)

Either way, it looks like it doesn't actually cleanup/uninstall any of the npm modules because they are all still there.

Here's the error I'm getting now when entering: **> npm list -g --depth=0**

I get: /usr/local/lib [email protected] [email protected] [email protected] [email protected] -error: ENOTDIR: not a directory, open '/usr/local/lib/node_modules/npm-debug.log/package.json

But I went back into my project directory and running: npm install gulp

both work! so I guess it's all working, but I must admit I really hate seeing error messages :)

ps. this forum text field sucks completely

bionary started a new conversation NPM Not Working

Hello,

New to Laravel.

npm was working for me last week, not sure what happened but now npm is completely crapping out.

I'm on OSX and simply running a simple >npm install gives this error:

Error: Cannot find module 'node-uuid'

Both node / npm are installed... node -v; npm -v; //v7.4.0 4.1.1

I'm not the best at CLI so if anyone can offer any specific / detailed advice that would surely appreciated!

Thanks.