archiebango

archiebango

Member Since 2 Years Ago

Firenze

Experience Points 1,530
Experience Level 1

3,470 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.

20 Nov
1 year ago

archiebango left a reply on How To Show All Name And Countries Based On Their ID From 2 Different Tables?

I got it but I'm not sure if this is a best practice.

->select('name') in model

Thanks guys, I believe I made a mistake, I should implement the Query builder instead Eloquent Relationship in large records.

archiebango left a reply on How To Show All Name And Countries Based On Their ID From 2 Different Tables?

Hi @RamjithAp

Do you have an alternative for? {{ $test->countries['name'] }} I got error on this undefined index but I think do I need to loop this?

{{ $test->countries[0]['name'] }} works but it only return 1 row.

P.S.

{{ $test->countries  }}
// This returns all array from table countries

Thanks

archiebango left a reply on How To Show All Name And Countries Based On Their ID From 2 Different Tables?

The answer in the above is right and that is the code that I am thinking in the first place. Got this error:

{{ $test->countries->name }} Property [name] does not exist on this collection instance

I am trying to search for this solution and maybe I can find the solution sooner.

archiebango left a reply on How To Show All Name And Countries Based On Their ID From 2 Different Tables?

Hi guys, this is my error: Trying to get property of non-object

//Countries Model
public function user(){
    return $this->hasMany(user::class, 'id');
    }
//users model
 public function countries(){
 return $this->belongsTo(countries::class, 'countries_id');
       }

Hi @rumm.an I tried to substitute the foreign_id from countries_id to id

18 Nov
1 year ago

archiebango left a reply on How To Show All Name And Countries Based On Their ID From 2 Different Tables?

hi @rumm.an

I got errors, does it mean I need a country_id for both countries table and users table ?

Thanks

archiebango started a new conversation How To Show All Name And Countries Based On Their ID From 2 Different Tables?

I have 2 tables, one is users while other is countries each of them have an ID. Example

// users
Mark is 1
John is 2
Cena is 1
//countries
Italy 1
France 2

How do I output it into

Mark - Italy
John - France
Cena - Italy

I have these relationship code but it only shows single row


public function Users(){
    return $this->hasMany(Countries::class,'id');    
}


public function Countries(){    
    return $this->hasMany(users::class,'countries_id');
    }

$whereYou = users::find(1)->countries;
17 Nov
1 year ago

archiebango left a reply on How To Add Auth In /employer/ And Beyond

Hi @Jaytee

Thanks, I got it. this is very helpful

archiebango left a reply on How To Add Auth In /employer/ And Beyond

Hi @Jaytee ,

if I am not mistaken, that code is for route ( web.php ) right?

Thanks

archiebango started a new conversation How To Add Auth In /employer/ And Beyond

Hi, how do I add Auth check in /employer/ and beyond like? /employer/profile/ or /employer/settings/ because the only authenticated is /employer/home/

I am using Hesto/Multi-auth Package I am not sure if this code are related:

<?php
// /routes/employer.php

Route::get('/home', function () {
    $users[] = Auth::user();
    $users[] = Auth::guard()->user();
    $users[] = Auth::guard('employer')->user();

    //dd($users);

    return view('employer.home');
})->name('home');

Thanks

archiebango left a reply on Error 404 But Route Is In The Route:list

Thanks mate, its working now

archiebango started a new conversation Error 404 But Route Is In The Route:list

employer/jobs/create return error 404. Weird, but it was enlisted in route:list.

//web.php
Route::get   ('employer/jobs/{job}/edit', '[email protected]')->name('employer.jobs.edit');
Route::get   ('employer/jobs/{job}', '[email protected]')->name('employer.jobs.show');
Route::post  ('employer/jobs', '[email protected]')->name('employer.jobs.store');
Route::get   ('employer/jobs','[email protected]')->name('employer.jobs.index');
Route::delete('employer/jobs/{job}', '[email protected]')->name('employer.jobs.destroy');
Route::get   ('employer/jobs/create','[email protected]')->name('employer.jobs.create');

Route::match(array('PUT', 'PATCH'), "/employer/jobs/{job}", array(
      'uses' => '[email protected]',
      'as' => 'employer.jobs.update'
));
GET|HEAD  | employer/jobs/create            | employer.jobs.create  | App\Http\Controllers\[email protected]  
//controller

public function create()
    {
        return view('employer.jobs.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
 
        request()->validate([
            'employers_name' => 'required',
           
        ]);
        EmployersJobs::create($request->all());
        return redirect()->route('employer.jobs.index')
                        ->with('success','Article created successfully');
    }

archiebango left a reply on Route: Show, Edit, And Delete Return 404 Or Not Found

Thank you @Snapey , are you my life-saver. I dont know why subpages are not working in laravel, it always return 404 in route::resource

16 Nov
1 year ago

archiebango left a reply on Route: Show, Edit, And Delete Return 404 Or Not Found

still doesn't work..

the URI from route:list below is wrong:

DELETE    | employer/jobs/{}                | employer.jobs.destroy
PUT|PATCH | employer/jobs/{}                | update 
GET|HEAD  | employer/jobs/{}                | employer.jobs.show
 GET|HEAD  | employer/jobs/{}/edit           | employer.jobs.edit

it should be:

DELETE    | employer/jobs/{jobs}                | employer.jobs.destroy
PUT|PATCH | employer/jobs/{jobs}                | update 
GET|HEAD  | employer/jobs/{jobs}                | employer.jobs.show
 GET|HEAD  | employer/jobs/{jobs}/edit           | employer.jobs.edit

any help for this? thanks

archiebango left a reply on Route: Show, Edit, And Delete Return 404 Or Not Found

Hi @Parasoul

thanks, I followed your instruction but I got error

"Cannot redeclare App\Providers\RouteServiceProvider::boot()"

Thanks

archiebango started a new conversation Route: Show, Edit, And Delete Return 404 Or Not Found

Hi,

show, edit, and delete return 404. I believe that the problem is in my routing (web.php) . could some figure out? Thanks

Route::group(['prefix' => 'jobs'], function() {
        Route::resource('/', 'EmployersJobController', [
            'names' => [
                'index' => 'employer.jobs.index',
                'create' => 'employer.jobs.create',
                'store' => 'employer.jobs.store',
                'show' => 'employer.jobs.show', //Problem 1
                'edit' => 'employer.jobs.edit', //Problem 2
                'destroy' => 'employer.jobs.destroy', //Problem 3
            ]
        ]);
    }); 
//controller 

public function edit($id)
    {
        $jobs = EmployersJobs::find($id);
        return view('employer.jobs.edit',compact('jobs'));
    }


public function show($id)
    {
        $jobs = EmployersJobs::findOrFail($id);
        return view('employer.jobs.show',compact('jobs'));
    }


public function destroy($id)
    {
        EmployersJobs::find($id)->delete();
        return redirect()->route('employer.jobs.index')
                        ->with('success','Article deleted successfully');
    }
// my view

<a class="btn btn-info" href="{{ route('employer.jobs.show',$job->id) }}">Show</a>
<a class="btn btn-primary" href="{{ route('employer.jobs.edit',$job->id) }}">Edit</a>

{!! Form::open(['method' => 'DELETE','route' => ['employer.jobs.destroy', $job->id],'style'=>'display:inline']) !!}

{!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
{!! Form::close() !!}
// route:list
//sorry for messy route list

 DELETE    | employer/jobs/{}                | employer.jobs.destroy | App\Http\Controllers\[email protected]                            | web                        |
|        | 

PUT|PATCH | employer/jobs/{}                | update                | App\Http\Controllers\[email protected]                             | web                        |
|        | 

GET|HEAD  | employer/jobs/{}                | employer.jobs.show    | App\Http\Controllers\[email protected]                               | web                        |
|        | 

GET|HEAD  | employer/jobs/{}/edit           | employer.jobs.edit    | App\Http\Controllers\[email protected]                               | web    

P.S. I tried this code below, but I always get route not define

//route not define
Route::resource('employer.jobs', 'EmployersJobController');
14 Nov
1 year ago

archiebango started a new conversation Method Does Not Exist

I am getting "Method [create] does not exist." is there any way to fix this? thanks

// php artisan route:list
GET|HEAD | employer/jobs/create | jobs.create |App\Http\Controllers\[email protected]             
// web.php
Route::group(['prefix' => 'employer'], function () {
  Route::get('/login', 'EmployerAuth\[email protected]')->name('login');
  Route::post('/login', 'EmployerAuth\[email protected]');
  Route::post('/logout', 'EmployerAuth\[email protected]')->name('logout');

  Route::get('/register', 'EmployerAuth\[email protected]')->name('register');
  Route::post('/register', 'EmployerAuth\[email protected]');

  Route::post('/password/email', 'EmployerAuth\[email protected]')->name('password.request');
  Route::post('/password/reset', 'EmployerAuth\[email protected]')->name('password.email');
  Route::get('/password/reset', 'EmployerAuth\[email protected]')->name('password.reset');
  Route::get('/password/reset/{token}', 'EmployerAuth\[email protected]');

Route::resource('jobs','EmployersJobController'); //possible culprit line??
});
// employer/jobs/index.blade.php

<a class="btn btn-success" href="{{ route('jobs.create') }}"> Create New Job</a>

//controller

   public function create()
    {
        return view('employer.jobs.create');
    }
13 Nov
1 year ago

archiebango left a reply on Eloquent Relationship: Inverse Question

Hi @RamjithAp

Thank you very much, it's working :)

I edit some here and I didnt now there's foreign key exist.

return $this->belongsTo(Employer::class,'id');

archiebango started a new conversation Eloquent Relationship: Inverse Question

Hi, I have 2 tables employers and employers_jobs. employers have a column of id and name while employers_jobs have a column of id employer_id and employers_job_title

the problem: the employers table returns null. I believe this called inverse relationship

here are some of my codes:

//Employer.php (model)
 public function EmployersJobs(){

        return $this->hasMany(EmployersJobs::class);
    }
//EmployersJobs.php (model) this might be the culprit
public function Employer(){

        return $this->belongsTo(Employer::class);
    }
//php artisan tinker, returns null
>>> App\EmployersJobs::find(1)->Employer;
=> null
//php artisan tinker
>>> App\Employer::find(1)->EmployersJobs;
//this is working
11 Nov
1 year ago

archiebango started a new conversation Trying To Get The Database Result But Not Showing

Hi,

I am trying to fetch data from database, but it's not showing in my view. I tried to follow the laravel 5.5 database instructions but didn't work. could some help me? thanks

//DatabaseTestController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\EmployersJobs;

class DatabaseTestController extends Controller
{
 public function index()
    {
      $users = EmployersJobs::select('select * from employers_jobs');

      return view('test', compact('users'));
    }

}
// test.blade.php
@foreach ($users as $user) {
     {{ $user->employers_name }}
}
@endforeach 
// web.php
Route::resource('test','DatabaseTestController');
// This is EmployersJob.php model
class EmployersJobs extends Model
{
    //
 protected $fillable = [
        'employers_name', 'employers_job_title', 'employers_job_summary', 'employers_job_salary', 'employers_job_location',
    ];    
}
09 Nov
1 year ago

archiebango left a reply on Controller Questions

Thank you guys for help and info. Cheers

08 Nov
1 year ago

archiebango started a new conversation Controller Questions

Hi,

Hi, I saw the tutorials online on how to create CRUD in laravel. Here is the link: http://itsolutionstuff.com/post/laravel-55-crud-example-from-scratchexample.html

I tried to understand and read the documentations of laravel but I can't really figure out what are these, could someone help me or guide me what's the use of these codes? Thanks in advance.

   public function index()
    {
        $articles = Article::latest()->paginate(5);
        return view('articles.index',compact('articles'))
            ->with('i', (request()->input('page', 1) - 1) * 5);
    }
  1. What is the Article from Article::latest() is this Model name?
  2. what is the articles from compact('articles') is that Route from web.php? Route::resource('articles','ArticlesController');

Thanks in advance.

24 Oct
1 year ago

archiebango started a new conversation Route Not Defined

Hi, I got a new error again, I cant still figure out and I need some help. Thank you very much

\ This is the error

"Route [createjobs.jobs] not defined. (View: /Applications/MAMP/htdocs/outsourcemo/resources/views/client/createjobs/create.blade.php)"
\ web.php
Route::resource('client/createjobs/','JobController');
\ create.blade.php

<a class="btn btn-primary" href="{{ route('createjobs.jobs') }}"<> Back</a>
\ JobController.php

  <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Job;

class JobController extends Controller
{
    //

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $jobs = Job::latest()->paginate(5);
        return view('client.createjobs.jobs',compact('jobs'))
            ->with('i', (request()->input('page', 1) - 1) * 5);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('client.createjobs.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        request()->validate([
            'jobTitle' => 'required',
            'jobPost' => 'required',
        ]);
        Job::create($request->all());
        return redirect()->route('client.createjobs.jobs')
                        ->with('success','Article created successfully');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $job = Job::find($id);
        return view('client.createjobs.show',compact('job'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $job = Job::find($id);
        return view('client.createjobs.edit',compact('job'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        request()->validate([
            'jobTitle' => 'required',
            'jobPost' => 'required',
        ]);
        Job::find($id)->update($request->all());
        return redirect()->route('client.createjobs.jobs')
                        ->with('success','Article updated successfully');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        Job::find($id)->delete();
        return redirect()->route('client.createjobs.jobs')
                        ->with('success','Article deleted successfully');
    }
}

23 Oct
1 year ago

archiebango left a reply on Route [client.createjobs.jobs] Not Defined

Thanks @tykus the route:list helps me a lot

archiebango started a new conversation Route [client.createjobs.jobs] Not Defined

Hi Guys, I need some help badly, after running the webpage, I got a error. Thanks a lot

Route [client.createjobs.jobs] not defined. (View: /Applications/MAMP/htdocs/outsourcemo/resources/views/client/createjobs/show.blade.php)"

I will show you some of my codes:

\\web.php
Route::group(['prefix' => 'client'], function () {
  Route::get('/login', 'ClientAuth\[email protected]')->name('login');
  Route::post('/login', 'ClientAuth\[email protected]');
  Route::post('/logout', 'ClientAuth\[email protected]')->name('logout');
});

Route::resource('/client/createjobs','JobController');
\\ JobController.php

public function index()
    {
        $jobs = Job::latest()->paginate(5);
        return view('client.createjobs.jobs',compact('jobs'))
            ->with('i', (request()->input('page', 1) - 1) * 5);
    }
\\ client/createjobs/show.blade.php

<div class="pull-right">
     <a class="btn btn-primary" href="{{ route('client.createjobs.jobs') }}"> Back</a>
</div>
18 Oct
1 year ago

archiebango started a new conversation Multiple Roles (`Admin`, `Members`) And Redirect And Authenticate

Hi,

I have a multiple role like admin, and member, and I have column in database name role. If the role is admin, it will redirect to /admin page in which members cant access.

What is the best practice for it? and some help to. I tried to check the answers in google but some are not working or outdated (laravel 5.5).

Thanks

archiebango left a reply on How To Add Dropdown Menu To Register.blade.php?

I figured out.

<?php echo Form::select('role', array('beta member' => 'beta member', 'member' => 'member'), 'member', array('id' => 'role', 'class' => 'from-control', 'value' => 'old("role")')); ?>

archiebango started a new conversation How To Add Dropdown Menu To Register.blade.php?

Hi, under register.blade.php, it has already default laravel form, the code is below. My question is how will I convert this code to Dropdown, I want to put 'Beta Member' and 'Member' role? I checked the laravel documentation and it is different on this so I am confused. I need some help, thank you.

<div class="form-group{{ $errors->has('role') ? ' has-error' : '' }}">
<label for="role" class="col-md-4 control-label">Role</label>

<div class="col-md-6">
<input id="role" type="text" class="form-control" name="role" value="{{ old('role') }}" required autofocus>

@if ($errors->has('role'))
<span class="help-block">
<strong>{{ $errors->first('role') }}</strong>
</span>
@endif
</div>
</div>
\\ According to Laravel Documentation, this is the code, but its way different from above
echo Form::select('size', array('L' => 'Large', 'S' => 'Small'), 'S', array('id' => 'your_id', 'class' => 'your_class'));
17 Oct
1 year ago

archiebango left a reply on Adding Username To Database(migration) Using Auth::user

hi @tisuchi and @ahuggins

Thank you very much, the codes are right. I didn't noticed the users column name is name and not username

Thanks a lot :)

archiebango left a reply on Adding Username To Database(migration) Using Auth::user

Hello guys,

I tried these but return nulls.

archiebango started a new conversation Adding Username To Database(migration) Using Auth::user

Hi,

Im using a Laravel Collective Form with form of username, post, location , but I want to modify some stuffs like instead of manually inputing my username (the Auth::user) into form, I want it to automatic add to database. but I have a serious problem, im new to laravel so I cant find the solution, I might find here. I believe the code is Auth::user()->username but I am not sure. Thanks

\\PostController.php

 public function store(Request $request)
    {
        request()->validate([
            'username' => 'required', //I will get rid of this
            'post' => 'required',
            'location' => 'required',
            
           
        ]);
        Post::create($request->all());

        return redirect()->route('post.index')
                        ->with('success','Post created successfully');
    }
//form.blade.php

<div class="row">
    <div class="col-xs-12 col-sm-12 col-md-12">
        <div class="form-group">
            <strong>Username:</strong>

            {!! Form::text('username', null, array('placeholder' => 'Username','class' => 'form-control')) !!} //I also want to get rid of this

        </div>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-12">
        <div class="form-group">
            <strong>Post:</strong>
            {!! Form::textarea('post', null, array('placeholder' => 'Post','class' => 'form-control','style'=>'height:150px')) !!}
        </div>
    </div>
    <strong>
     {!! Form::textarea('location', null, array('placeholder' => 'Location','class' => 'form-control','style'=>'height:150px')) !!}
     </strong>

    

    <div class="col-xs-12 col-sm-12 col-md-12 text-center">
            <button type="submit" class="btn btn-primary">Submit</button>
    </div>
</div>
//I include the index.blade.php, just an additional information, Thanks
//post/index.blade.php

@extends('layouts.app')

@section('content')
    <div class="row">
        <div class="col-lg-12 margin-tb">
            <div class="pull-left">
                <h2>Archievald Post Sample Test</h2>
            </div>
            <div class="pull-right">
                <a class="btn btn-success" href="{{ route('post.create') }}"> Create New Post</a>
            </div>
        </div>
    </div>

    @if ($message = Session::get('success'))
        <div class="alert alert-success">
            <p>{{ $message }}</p>
        </div>
    @endif

    <table class="table table-bordered">
        <tr>
            <th>ID</th>
            <th>Username</th>
            <th>Post</th>
            <th>Location</th>
            <th>Created at</th>
           
            <th width="280px">Action</th>
          
        </tr>
    @foreach ($posts as $post)
    <tr>
        <td>{{ $post->id }}</td>
        
        <td>{{ $post->username}}</td>
        <td>{{ $post->post}}</td>
          <td>{{ $post->location}}</td>
            <td>{{ $post->created_at}}</td>
        <td>
            <a class="btn btn-info" href="{{ route('post.show',$post->id) }}">Show</a>
            <a class="btn btn-primary" href="{{ route('post.edit',$post->id) }}">Edit</a>
            {!! Form::open(['method' => 'DELETE','route' => ['post.destroy', $post->id],'style'=>'display:inline']) !!}
            {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
            {!! Form::close() !!}
        </td>
       
    </tr>
    @endforeach
    </table>

    {!! $posts->links() !!}
@endsection

archiebango left a reply on "Undefined Variable: Posts "

@tisuchi

Thank you very much. Im trying to figure out for almost an hour. :) cheers

archiebango started a new conversation "Undefined Variable: Posts "

Hi, I have a new problem. I am trying to figure out why I am getting this error. Everytime I check the variable and syntax seems ok. kindly help me for this project? Thank You so much

//index.blade.php

 @foreach ($posts as $post) // this line is the main culprit
    <tr>
        <td>{{ $post->id }}</td>
        
        <td>{{ $post->username}}</td>
        <td>{{ $post->post}}</td>
//PostController.php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Post;

........
.........
public function index()
    {
        $posts = Post::latest()->paginate(5);
        return view('post.index',compact('post'))
            ->with('i', (request()->input('page', 1) - 1) * 5);
    }
//Post.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    //
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'username', 'post'
    ];
}
16 Oct
1 year ago

archiebango left a reply on "Trying To Get Property Of Non-object"

thanks @topvillas , working miraculously

archiebango started a new conversation "Trying To Get Property Of Non-object"

Hi, I have an error "Trying to get property of non-object" in show.blade.php particularly na $post. Anyone can help me to fix this? Thank you very much, here is my codes:

//show.blade.php
<div class="col-xs-12 col-sm-12 col-md-12">
            <div class="form-group">
                <strong>Username:</strong>
                {{ $post->username }}
            </div>
        </div>
//PostController.php
  public function show($id)
    {
        $post = Post::find($id);
        return view('post.show',compact('post'));
    }
//Post.php
class Post extends Model
{
    //
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'username', 'post'
    ];
}

archiebango left a reply on Controller Question (CRUD)

@andonovn

Thank you very much. I tried to understand, read their documentation and google it, but I am still confused. Your explanation is clear.

Thank you very much for your time and effort. Cheers

archiebango started a new conversation Controller Question (CRUD)

Hi, I need some questions, I want to know how these codes work. I am trying to figure out but I know these codes are for displaying with pages right? Could someone enlighten or explain me piece-by-piece code.

Thanks so much

This is the entire code

public function index()
    {
        $articles = Article::latest()->paginate(5);
        return view('articles.index',compact('articles'))
            ->with('i', (request()->input('page', 1) - 1) * 5);
    }

public function store(Request $request)
    {
        request()->validate([
            'title' => 'required',
            'body' => 'required',
        ]);
        Article::create($request->all());
        return redirect()->route('articles.index')
                        ->with('success','Article created successfully');
    }

Question 1: I still cant understand why there's so many numbers and what is the purpose of with() and 'i' ?

 ->with('i', (request()->input('page', 1) - 1) * 5);

Question 2: What is this for? why request() and ->validate?

request()->validate([
            'title' => 'required',
            'body' => 'required',
        ]);

Question 3:

Article::create($request->all());
        return redirect()->route('articles.index')
                        ->with('success','Article created successfully');

Question 4: what is the purpose of this?

->

Thank you very much

14 Oct
1 year ago

archiebango started a new conversation Class "classname" Not Found In DB:SEED

Hi,

I have a real problem, I have an error:

[Symfony\Component\Debug\Exception\FatalThrowableError]  
  Class 'Picnic' not found   

Here is my codes (P.S. I didnt include all codes, only the important ones):

In databaseseeder.php

use Illuminate\Database\Seeder;
use App\Bear;
use App\Fish;
use App\Picnic;
use App\Tree;

..... 
.....
......

        // link our bears to picnics ---------------------
        // for our purposes we'll just add all bears to both picnics for our many to many relationship
        $bearLawly->picnics()->attach($picnicYellowstone->id);
        $bearLawly->picnics()->attach($picnicGrandCanyon->id);

        $bearCerms->picnics()->attach($picnicYellowstone->id);
        $bearCerms->picnics()->attach($picnicGrandCanyon->id);

        $bearAdobot->picnics()->attach($picnicYellowstone->id);
        $bearAdobot->picnics()->attach($picnicGrandCanyon->id);

        $this->command->info('They are terrorizing picnics!');

    }

}

Here is the main culprit, It seems the Picnic class is not found but I have a Picnic class. Bear.php

//This is the main culprit ('Picnic',)
public function picnics() {
        return $this->belongsToMany('Picnic', 'bears_picnics', 'bear_id', 'picnic_id');

Picnic.php
class Picnic extends Model
{
    //
    // MASS ASSIGNMENT -------------------------------------------------------
    // define which attributes are mass assignable (for security)
    // we only want these 3 attributes able to be filled
    protected $fillable = array('name', 'taste_level');

    // DEFINE RELATIONSHIPS --------------------------------------------------
    // define a many to many relationship
    // also call the linking table
    public function bears() {
        return $this->belongsToMany('Bear', 'bears_picnics', 'picnic_id', 'bear_id');
    }
}

composer autoload doesn't fix

13 Oct
1 year ago

archiebango left a reply on How Create Column In Phpmyadmin?

Hey guys, I found the culprit

  1. Check your config/database.php (Port number: 8889, host: localhost)
  2. go to terminal and perform the following(s)
composer dump
php artisan migrate:fresh
php artisan migrate

then viola. it works now

archiebango left a reply on How Create Column In Phpmyadmin?

@sutherland tried this and I got a new error

 [Illuminate\Database\QueryException]                                         
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t  
  oo long; max key length is 767 bytes (SQL: alter table `users` add unique `  
  users_email_unique`(`email`))        

and now i'm working on these errors, maybe I can find some solution

archiebango started a new conversation How Create Column In Phpmyadmin?

Hi, I tried several steps to create a migrations (database) in Laravel.

In terminal, I input

1st

php artisan make:migration JobSeekerPosts

In JobSeekerPosts.php

2nd

public function up()
    {
        //
          Schema::table('JobSeekerPosts', function (Blueprint $table) {
          $table->string('SeekerPosts');
        });
    }

3rd

php artisan migrate

then nothing happens... the phpMyAdmin database has no JobSeekerPosts and I only see 'migrations' table and I have error in terminal

[Illuminate\Database\QueryException]                                         
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' alre  
  ady exists (SQL: create table `users` (`id` int unsigned not null auto_incr  
  ement primary key, `name` varchar(255) not null, `email` varchar(255) not n  
  ull, `password` varchar(255) not null, `remember_token` varchar(100) null,   
  `created_at` timestamp null, `updated_at` timestamp null) default character  
   set utf8mb4 collate utf8mb4_unicode_ci)  
[PDOException]                                                               
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' alre  
  ady exists      

anyone have fix on these? thanks

04 Sep
1 year ago

archiebango left a reply on I Got Suggestions And Errors In Terminal After Creating New Project In Laravel

@papa Hi, I created a lot but I still got "Whoops" errors. I tried using MAMP or php artisan serve, both of them are not working, but my old system is still working.

archiebango started a new conversation I Got Suggestions And Errors In Terminal After Creating New Project In Laravel

I got errors and suggestions in terminal after creating a new project, I also did the global composer update but after loading the page, I got "Whoops, looks like something went wrong."

any help please? thanks

symfony/var-dumper suggests installing ext-symfony_debug ()
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/dependency-injection (For loading routes from a service)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/http-kernel suggests installing symfony/browser-kit ()
symfony/http-kernel suggests installing symfony/class-loader ()
symfony/http-kernel suggests installing symfony/config ()
symfony/http-kernel suggests installing symfony/dependency-injection ()
symfony/console suggests installing symfony/filesystem ()
egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
ramsey/uuid suggests installing ext-libsodium (Provides the PECL libsodium extension for use with the SodiumRandomGenerator)
ramsey/uuid suggests installing ext-uuid (Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator)
ramsey/uuid suggests installing ircmaxell/random-lib (Provides RandomLib for use with the RandomLibAdapter)
ramsey/uuid suggests installing moontoast/math (Provides support for converting UUID to 128-bit integer (in string form).)
ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
symfony/translation suggests installing symfony/config ()
symfony/translation suggests installing symfony/yaml ()
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver and SES mail driver (~3.0).)
laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (~2.5).)
laravel/framework suggests installing guzzlehttp/guzzle (Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~6.0).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (~1.0).)
laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
laravel/framework suggests installing nexmo/client (Required to use the Nexmo transport (~1.0).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (~3.0).)
laravel/framework suggests installing predis/predis (Required to use the redis cache and queue drivers (~1.0).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (~2.0).)
laravel/framework suggests installing symfony/dom-crawler (Required to use most of the crawler integration testing tools (~3.3).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to psr7 bridging features (~1.0).)
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit.)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.5)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
Application ready! Build something amazing.
31 Jul
2 years ago

archiebango left a reply on ReflectionException Class Client Does Not Exist

hi @Snapey no errors so far

App\Http\Middleware\ClientMiddleware {#702}

archiebango left a reply on ReflectionException Class Client Does Not Exist

Hi @Snapey ,

I found an error but still I can't figure out...

PHP Fatal error:  Undefined constant App\Http\Middleware\ClientMiddleware in eval()'d code on line 1

here is my code in ClientMiddleware.php

<?php

namespace App\Http\Middleware;

use Closure;

class ClientMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
   public function handle($request, Closure $next)
    {
        if(Auth::user()->role == "client")
            return $next($request);
        return redirect('/');
    }
}
30 Jul
2 years ago

archiebango left a reply on ReflectionException Class Client Does Not Exist

Hi @Snapey ,

Yes they are the same lettercase.

I tried the new App\Http\Middleware\ClientMiddleware.php in terminal but I have error

Archievalds-MacBook-Air:ProjectArchie archievald$ new App/Http/Middleware/ClientMiddleware.php
-bash: new: command not found