jet

jet

Member Since 3 Months Ago

Experience Points 1,010
Experience
Level
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

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

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

15 Dec
1 day ago

jet left a reply on Method Illuminate\Validation\Validator::validateReqiured Does Not Exist.

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AdmissionRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'program'     => 'reqiured|max:250',
            'level'       => 'reqiured|max:250',
            'requirement' => 'reqiured|max:250',
            'status'      => 'reqiured|max:250',
            'slug'        => 'reqiured|max:250',
            'university_id' => 'required|numeric',
            'user_id'     => 'required|numeric'
        ];
    }
}

jet started a new conversation Class App\Http\Requests\ScholarshipRequest Does Not Exist

need help don't know what am doing wrong

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests\ScholarshipRequest;
use App\Scholarship; 
use Auth;
use Session;

class ScholarshipController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
         $scholarships = Scholarship::all();
        return view('scholarship.index', ['scholarships' => $scholarships]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
         $scholarship = new Scholarship();
        return view('scholarship.form', ['scholarship' => $scholarship, 'action' => 'create', 'countries' => $scholarship->getCountries()]);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(ScholarshipRequest $request)
    {
        $validated = $request->validated();
        $data = $request->input();
        unset($data['_token']);
        $data['user_id'] = Auth::id();

        if(Scholarship::create($data)) {
            
            Session::flash('success', 'sucessfully save!');
            return redirect('/scholarships');
        } else {
            return 'there was an error';
        }

      
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
         $scholarship = Scholarship::findOrFail($id);
        return view('Scholarship.show', ['scholarship' => $scholarship]);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $scholarship = Scholarship::findOrFail($id);
        return view('scholarship.form', ['scholarship' => $scholarship, 'action' => 'edit', 'countries' => $scholarship->getCountries()]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(ScholarshipRequest $request, $id)
    {
        $validated = $request->validated();
        $data = $request->input();
        unset($data['_token']);
        unset($data['_method']);
        $data['user_id'] = Auth::user()->id;

        if(Scholarship::where('id', $id)->update($data)) {
            $data = $request->all();
            Session::flash('success', 'Scholarship sucessfully updated!');
            return redirect('/scholarships');
        } else {
            return 'there was an error';
        }

        $data->save();
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
         if (Scholarship::findOrFail($id)->delete()) {
            return response()->json('');
            Session::flash('success', 'The scholarship was sucessfully deleted.');
        } else {
            return 'there was an error';
        }
    }
}

jet started a new conversation Method Illuminate\Validation\Validator::validateReqiured Does Not Exist.

pls help

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests\AdmissionRequest;
use App\models\University;
use App\models\Admission;
use Auth; 
use Session;



class AdmissionController extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        $admissions = Admission::all();

        return view('admission.index', ['admissions' => $admissions]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $admission = new Admission();
        return view('admission.form', ['admission' => $admission, 'action' => 'create', 'universities' => University::all()]);
    }


    /**
     *
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(AdmissionRequest $request)
    {
        $validated = $request->validated();
        $data = $request->input();
        unset($data['_token']);
        $data['user_id'] = Auth::id();
        $data['slug'] = $data['program'] .'-'. $data['level']. '-20180'. $data['university_id'];

        if(Admission::create($data)) {

             Session::flash('success', 'sucessfully save!');
            return redirect('/admissions');
        } else {
            return 'there was an error';
        }

    }

    /**
     * Display the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $admission = Admission::findOrFail($id);
        return view('admission.show', ['admission' => $admission]);

    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $admission = Admission::findOrFail($id);
        return view('admission.form', ['admission' => $admission, 'action' => 'edit', 'universities' => University::all()]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function update(AdmissionRequest $request, $id)
    {

        $validated = $request->validated();
        $data = $request->input();
        unset($data['_token']);
        unset($data['_method']);
        $data['user_id'] = Auth::user()->id;
        $data['slug'] = str_replace(' ', '-', strtolower($data['program'])) .'-'. str_replace(' ', '-', strtolower($data['level'])). '-20180'. $data['university_id'];

        if(Admission::where('id', $id)->update($data)) {

            Session::flash('success', 'sucessfully save!');
            return redirect('/admissions');
        } else {
            return 'there was an error';
        }

    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
        if (Admission::findOrFail($id)->delete()) {
            return response()->json('');
        } else {
            return 'there was an error';
        }
    }

}

14 Dec
2 days ago

jet started a new conversation How Can I Add A Validation Rules In The Controller And Form

controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\models\University;
use Auth;
use Session; 

class UniversityController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        $universities = University::all();
        return view('university.index', ['universities' => $universities]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $university = new University();
        return view('university.form', ['university' => $university, 'action' => 'create', 'countries' => $university->getCountries()]);
    }


    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

        $data = $request->input();
        unset($data['_token']);
        $data['user_id'] = Auth::id();
        if ($request->hasFile('logo')) {
            $data['logo'] = $request->file('logo')->store('public');
        }
        if(University::create($data)) {
             $data = $request->all();    
            Session::flash('success', 'sucessfully save!');
            return redirect('/universities');
        } else {
            return 'there was an error';
        }

          $data->save();
             
    }


    /**
     * Display the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $university = University::findOrFail($id);
        return view('university.show', ['university' => $university]);

    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $university = University::findOrFail($id);
        return view('university.form', ['university' => $university, 'action' => 'edit', 'countries' => $university->getCountries()]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
        $data = $request->input();      
        unset($data['_token']);
        unset($data['_method']);
        $data['user_id'] = Auth::user()->id;
        if ($request->hasFile('logo')) {
            $data['logo'] = $request->file('logo')->store('public');
        }
        if(University::where('id', $id)->update($data)) {
             $data = $request->all();
             Session::flash('success', 'sucessfully save!');
            return redirect('/universities');
        } else {
            return 'there was an error';
        }

        $data->save();
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
        if (University::findOrFail($id)->delete()) {
            return response()->json('');
        } else {
            return 'there was an error';
        }
    }
}

form

 <div class="row">
    @if($university->id)
      <form method="POST" action="/universities/{{$university->id}}" enctype="multipart/form-data" class="col-md-12">
        <input type="hidden" name="_method" value="PUT" />
    @else
      <form method="POST" action="/universities" enctype="multipart/form-data" class="col-md-12">
    @endif
      {{ csrf_field() }}

        <input type="hidden" name="id" value="{{$university->id}}" />

      <div class="row">
      <div class="col-md-6 form-group">
        <label>Name</label>
        <input type="text" name="name" placeholder="Name" value="{{$university->name}}" class="form-control" />
      </div>
      <div class="col-md-6 form-group">
        <label>Country</label>
        <select type="text" name="country" placeholder="Name" class="form-control"  >
          <option>
            Select Country
          </option>
          @foreach ($countries as $cat)
            <option
              value="{{$cat}}"
              @if($cat === $university->country)
                selected = "selected"
              @endif
              >
              {{$cat}}
            </option>
          @endforeach

        </select>
      </div>
      </div>
      <div class="form-group">
        <label>About</label>
        <textarea name="about" placeholder="About" class="form-control ckeditor">{!! $university->about !!}</textarea>
      </div>
        <div class="row">
          <div class="col-md-6 form-group">
            <label>Address</label>
            <input type="text" name="address" placeholder="Address" value="{{$university->address}}" class="form-control" />
          </div>
          <div class="col-md-6 form-group">
            <label>Logo</label><br />
            <input type="file" name="logo" placeholder="Photo" value="{{$university->logo}}"  />
          </div>
        </div>

13 Dec
3 days ago

jet started a new conversation SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'name' In 'order Clause'

posts controller

class PostsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */

    public function index()
    {
        if (request()->has('t') && request()->t == 'p') {
            $posts = Post::where('type', 'page')->orderBy('name', 'asc')->paginate(20);
            $view = 'page';
        }
        else {
            $posts = Post::where('type', 'post')->orderBy('name', 'asc')->paginate(20);
            $view ='post';
        }

        return view('posts.index', ['posts' => $posts, 'view' => $view ]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories = Category::all();
        return view('posts.create', ['categories' => $categories]);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

        $data = $request->input();
        unset($data['_token']);
        $data['user_id'] = Auth::id();

        $this->validate($request, array(
                'title' => 'required|max:255',
        ));

        $post = new Post;

        $post->title = $request->title;
        $post->category_id = $request->category_id;
        $post->content = $request->content;
        $post->order = $request->order;
        $post->views = $request->views;
        $post->status = $request->status;
        $post->slug  = str_slug($request->title);
        $post->meta = $request->meta;


        $post->save();

        Session::flash('success', 'sucessfully save!');
        return redirect()->route('posts.index', $post->id);
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $post = Post::find($id);
        return view('posts.show')->withPost($post);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {

        $post = Post::find($id);
        $categories = Category:: all();
        $cats = array();
        foreach ($categories as $category) {
            $cats[$category->id] = $category->name;
        }

        return view('posts.edit', ['post' => $post, 'categories' => $cats]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {

        $data = $request->input();      
        unset($data['_token']);
        unset($data['_method']);
        $data['user_id'] = Auth::user()->id;

         $this->validate($request, array(
                'title' => 'required|max:255'
        ));

         $post = Post::find($id);

        $post->title = $request->input('title');
        $post->category_id = $request->input('category_id');
        $post->content = $request->input('content');
        $post->order = $request->input('order');
        $post->views = $request->input('views');
        $post->status = $request->input('status');
        $post->slug  = str_slug($request->input('title'));
        $post->meta = $request->input('meta');

        $post->save();

        Session::flash('success', 'This post was successfully updated');

        return redirect()->route('posts.show', $post->id);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
         $post = Post::find($id);

        $post->delete();

        Session::flash('success', 'The post was sucessfully deleted.');
        return redirect()->route('posts.index');
    }
}

11 Dec
5 days ago

jet started a new conversation Trying To Get Property 'id' Of Non-object

i need help

university controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\models\University;
use Auth;
use Session;

class UniversityController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
        $universities = University::all();

        return view('university.index', ['universities' => $universities]);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $university = new University();
        return view('university.form', ['university' => $university, 'action' => 'create', 'countries' => $university->getCountries()]);
    }


    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {

        $data = $request->input();
        unset($data['_token']);
        $data['user_id'] = Auth::user()->id;
        if ($request->hasFile('logo')) {
            $data['logo'] = $request->file('logo')->store('public');
        }
        if(University::create($data)) {
            Session::flash('success', 'sucessfully save!');
            return redirect('/universities');
        } else {
            return 'there was an error';
        }

             $this->validate($request, array(
                'name' => 'required|max:255',          
                'about' => 'required|max:255',          
                'country' => 'required|max:255',          
                'address' => 'required|max:255',          
        ));

        $university = new University;

        $university->name = $request->name;
        $university->about = $request->about;
        $university->country = $request->country;
        $university->address = $request->address;

        $university->save();

        Session::flash('success', 'sucessfully save!');
    }


    /**
     * Display the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $university = University::findOrFail($id);
        return view('university.show', ['university' => $university]);

    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $university = University::findOrFail($id);
        return view('university.form', ['university' => $university, 'action' => 'edit', 'countries' => $university->getCountries()]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
        $data = $request->input();
        unset($data['_token']);
        unset($data['_method']);
        $data['user_id'] = Auth::user()->id;
        if ($request->hasFile('logo')) {
            $data['logo'] = $request->file('logo')->store('public');
        }
        if(University::where('id', $id)->update($data)) {

            return redirect('/universities');
        } else {
            return 'there was an error';
        }
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
        if (University::findOrFail($id)->delete()) {
            return response()->json('');
        } else {
            return 'there was an error';
        }
    }
}


index form

@extends('layouts.admin')


@section('content')

    <h3>All Universities</h3>

    <p>
        <a href="/admissions" class="btn btn-warning btn-sm">Programs</a>
      <a href="/universities/create" class="btn btn-success btn-sm">Add University</a>
    </p>
    @if ($universities->count() > 0)
    <div class="table-responsive">
      <table class="table table-striped">
        <tr>
          <th>
             Logo
          </th>
          <th>
            Name
          </th>
          <th>
            Address
          </th>

          <th>
            Actions
          </th>
        </tr>
        @foreach($universities as $university)
          <tr>
            <td>
               <img class="" src="{{asset($university->logo)}}" width="50" />
            </td>
            <td>
              <a href="/universities/{{$university->id}}" >{{$university->name}}</a>
            </td>
            <td>
              {{$university->address}}
            </td>

            <td>
              <form  onsubmit="deleteItem(event,'/universities/{{$university->id}}', 'University' )" style="display: inline-block;">
                {{ csrf_field() }}
                <input type="hidden" name="_method" value="DELETE">
                <button type="submit" class="btn btn-danger btn-sm">Delete</button>
              </form>
              <a href="/universities/{{$university->id}}/edit" class="btn btn-primary btn-sm">Edit</a>
            </td>
          </tr>
        @endforeach
      </table>
    </div>
   @else
       <p>
         You have no universities at the moment.
       </p>
   @endif




@endsection

07 Dec
1 week ago

jet left a reply on Laravel Ckeditor Display Row Data In The Database And Post Form

@AMK - yes without it giving me the raw data that is with the tags attached to it

jet started a new conversation Laravel Ckeditor Display Row Data In The Database And Post Form

create form

<div class="form-group">
                    <label for="content">Content</label>
                    <textarea name="content" id="content" required class="form-control" rows="5" placeholder="Content"></textarea>
                </div>

                <div class="form-group">
                    <label for="status">Status</label>
                        <select class="custom-select" name="status" id="status" required>
                          <option value="1">Mr</option>
                          <option value="2">Mis</option>
                          <option value="3">male</option>
                        </select>
                </div>  
                
                <br>
                
                <input class="btn btn-success btn-lg btn-block" type="submit" value="Create post">
            </form>
        </div>
    </div>
@endsection

@section('scripts')
     <script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
     <script src="/vendor/unisharp/laravel-ckeditor/adapters/jquery.js"></script>
    <script>
        CKEDITOR.replace( 'content' );
    </script>
@endsection
06 Dec
1 week ago

jet started a new conversation Undefined Variable: Categories (View: E:\lara-test1\resources\views\posts\create.blade.php)

@extends('main')

@section('title', '| Ceate New Post')

@section('content')

@section('content')
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <h1>Create New Post</h1>
            <hr>
            <form name="ceate" action="/posts"  method="post">
                {{ csrf_field() }}
                <div class="form-group">
                    <label for="title">Titel</label>
                    <input type="text" name="title" required id="title" class="form-control" placeholder="Titel">
                </div>

                <div class="form-group">
                    <label for="order">Order</label>
                    <input type="text" name="order" required id="order" class="form-control" placeholder="Order">
                </div>

                <div class="form-group">
                    <label for="category_id">Category</label>
                        <select class="custom-select" name="category_id" id="category_id"  required> 
                            @foreach($categories as $category)
                                <option value="{{ $category->id }}">{{ $category->name }}</option>
                            @endforeach
                        </select>
                </div>
                
                <div class="form-group">
                    <label for="content">Content</label>
                    <textarea name="content" id="content" required class="form-control" rows="5" placeholder="Content"></textarea>
                </div>

                <div class="form-group">
                    <label for="status">Status</label>
                        <select class="custom-select" name="status" id="status" required>
                          <option value="1">One</option>
                          <option value="2">Two</option>
                          <option value="3">Three</option>
                        </select>
                </div>  
                
                <br>
                
                <input class="btn btn-success btn-lg btn-block" type="submit" value="Create post">
            </form>
        </div>
    </div>
@endsection

post controller

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Post;
use App\Category;
use Session;


class PostsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
     
    public function index()
    {
        $posts = Post::orderBy('id', 'desc')->paginate(10);
        return view('posts.index')->withPosts($posts);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories = Category::all(); 
        return view('posts.create')->withCategories($categories); 
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, array(
                'title' => 'required|max:255',
                
                
        ));

        $post = new Post;

        $post->title = $request->title;
        $post->category_id = $request->category_id;
        $post->content = $request->content;
        $post->order = $request->order;
        $post->views = $request->views;
        $post->status = $request->status;
        $post->slug  = str_slug($request->title);
        $post->meta = $request->meta;
        

        $post->save();

        Session::flash('success', 'sucessfully save!');
        return redirect()->route('posts.index', $post->id);
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $post = Post::find($id);
        return view('posts.show')->withPost($post);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $post = Post::find($id);
        $categories = Category:: all();
        $cats = array();
        foreach ($categories as $category) {
            $cats[$category->id] = $category->name;
        }

        return view('posts.edit', ['post' => $post, 'categories' => $cats]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
         $this->validate($request, array(
                'title' => 'required|max:255'            
        ));

         $post = Post::find($id);

        $post->title = $request->input('title');
        $post->category_id = $request->input('category_id');
        $post->content = $request->input('content');
        $post->order = $request->input('order');
        $post->views = $request->input('views');
        $post->status = $request->input('status');
        $post->slug  = str_slug($request->input('title'));
        $post->meta = $request->input('meta');

        $post->save();

        Session::flash('success', 'This post was successfully updated');

        return redirect()->route('posts.show', $post->id);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
         $post = Post::find($id);

        $post->delete();

        Session::flash('success', 'The post was sucessfully deleted.');
        return redirect()->route('posts.index');
    }
}

will be glad if any one can help

jet left a reply on Array_keys() Expects Parameter 1 To Be Array, Integer Given

To fix this you need to check at the laravel version of your project an copy the vendor form another working or new project and post-it to your project.

05 Dec
1 week ago

jet left a reply on Trying To Get Property 'name' Of Non-object (View: E:\lara-test\resources\views\posts\show.blade.php)

@REALRANDYALLEN - post model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    //protected $fillable = ['views','1'];
    public function posts(){
        return $this->belongsTo('App\Category');
    }
}

jet left a reply on Trying To Get Property 'name' Of Non-object (View: E:\lara-test\resources\views\posts\show.blade.php)

@REALRANDYALLEN - this is the post controller

class PostsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
     
    public function index()
    {
        $posts = Post::orderBy('id', 'desc')->paginate(10);
        return view('posts.index')->withPosts($posts);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories = Category::all(); 
        return view('posts.create')->withCategories($categories); 
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, array(
                'title' => 'required|max:255',
                
                
        ));

        $post = new Post;

        $post->title = $request->title;
        $post->category_id = $request->category_id;
        $post->content = $request->content;
        $post->order = $request->order;
        $post->views = $request->views;
        $post->status = $request->status;
        $post->slug  = str_slug($request->title);
        $post->meta = $request->meta;
        

        $post->save();

        Session::flash('success', 'sucessfully save!');
        return redirect()->route('posts.index', $post->id);
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $post = Post::find($id)->with('category')->first();
        return view('posts.show')->withPost($post);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $post = Post::find($id);
        $categories = Category:: all();
        $cats = array();
        foreach ($categories as $category) {
            $cats[$category->id] = $category->name;
        }

        return view('posts.edit')->withPost($post)->withCategories($cats);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
         $this->validate($request, array(
                'title' => 'required|max:255'            
        ));

         $post = Post::find($id);

        $post->title = $request->input('title');
        $post->category_id = $request->input('category_id');
        $post->content = $request->input('content');
        $post->order = $request->input('order');
        $post->views = $request->input('views');
        $post->status = $request->input('status');
        $post->slug  = str_slug($request->input('title'));
        $post->meta = $request->input('meta');

        $post->save();

        Session::flash('success', 'This post was successfully updated');

        return redirect()->route('posts.show', $post->id);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
         $post = Post::find($id);

        $post->delete();

        Session::flash('success', 'The post was sucessfully deleted.');
        return redirect()->route('posts.index');
    }
}

jet started a new conversation Trying To Get Property 'name' Of Non-object (View: E:\lara-test\resources\views\posts\show.blade.php)

show form

@section('content')

    <div class="row">
        <div class="col-md-8">
            <h1>{{ $post->title }}</h1>
            <h4>{{ $post->order }}</h4>
            <h4>{{ $post->category_id }}</h4>
            <p class="lead">{{ $post->content }}</p>
            <h4>{{ $post->status }}</h4>
        </div>

        <div class="col-md-4">
            <div class="well">

                <dl class="dl-horizontal">
                    <lable>Category:</lable>
                    <p>{{ $post->category->name }}</p>
                </dl>

                <dl class="dl-horizontal">
                    <lable>Create At:</lable>
                    <p>{{ date('M j, Y h:ia', strtotime($post->created_at)) }}</p>
                </dl>

category controller

 public function index()
    {
        $categories = Category::all();
       
        return view('categories.index')->withCategories($categories);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //Save a new category an then redirect back ti index
        $this->validate($request, array(
            'name' => 'required|max:255'
        ));
         $category = new Category;

         $category->name = $request->name;
         $category->save();

         Session::flash('success', 'New Category has been created');

         return redirect()->route('categories.index');
    }

jet left a reply on How Can I Add A New Repo From An Existing Project And Connect It To Github Or Gitlab

@SUSTAINED - want to add a git init into my project and upload it to gitlab

jet started a new conversation Invalid Argument Supplied For Foreach() (View: E:\lara-test\resources\views\posts\create.blade.php)

this is the create form

@extends('main')

@section('title', '| Ceate New Post')

@section('content')

@section('content')
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <h1>Create New Post</h1>
            <hr>
            <form name="ceate" action="/posts"  method="post">
                {{ csrf_field() }}
                <div class="form-group">
                    <label for="title">Titel</label>
                    <input type="text" name="title" required id="title" class="form-control" placeholder="Titel">
                </div>

                <div class="form-group">
                    <label for="order">Order</label>
                    <input type="text" name="order" required id="order" class="form-control" placeholder="Order">
                </div>
                <div class="form-group">
                    <label for="category_id">Category</label>
                        <select class="custom-select" name="category_id" id="category_id"  required> 
                            @foreach($categories as $category)
                                <option value='{{ $category->id }}'>{{ $category->name }}</option>
                            @endforeach
                        </select>
                </div>
                <div class="form-group">
                    <label for="content">Content</label>
                    <textarea name="content" id="content" required class="form-control" rows="5" placeholder="Content"></textarea>
                </div>

                <div class="form-group">
                    <label for="status">Status</label>
                        <select class="custom-select" name="status" id="status" required>
                          <option value="1">One</option>
                          <option value="2">Two</option>
                          <option value="3">Three</option>
                        </select>
                </div>  
                
                <br>
                
                <input class="btn btn-success btn-lg btn-block" type="submit" value="Create post">
            </form>
        </div>
    </div>
@endsection

the category controller

class CategoryController extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $categories = Category::all();
       
        return view('categories.index')->withCategories($categories);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //Save a new category an then redirect back ti index
        $this->validate($request, array(
            'name' => 'required|max:255'
        ));
         $category = new Category;

         $category->name = $request->name;
         $category->save();

         Session::flash('success', 'New Category has been created');

         return redirect()->route('categories.index');
    }

the post controller form

class PostsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
     
    public function index()
    {
        $posts = Post::orderBy('id', 'desc')->paginate(10);
        return view('posts.index')->withPosts($posts);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $categories = Category::all(); 
        return view('posts.create')->withCategories('$categories'); 
    }

    /**

please i need help

03 Dec
1 week ago

jet started a new conversation How Can I Add A New Repo From An Existing Project

Anyone ,please help

29 Nov
2 weeks ago

jet left a reply on Integrity Constraint Violation: 1048 Column 'category_id' Cannot Be Null (SQL: Insert Into `posts`

my form

<form name="ceate" action="/posts"  method="post">
                {{ csrf_field() }}
                <div class="form-group">
                    <label for="title">Titel</label>
                    <input type="text" name="title" required id="title" class="form-control" placeholder="Titel">
                </div>

                <div class="form-group">
                    <label for="order">Order</label>
                    <input type="text" name="order" required id="order" class="form-control" placeholder="Order">
                </div>

                <div class="form-group">
                    <label for="category_id" name="category_id" id="category_id" required>Category</label>
                        <select class="custom-select">
                          <option selected>Category</option>
                          <option value="1">One</option>
                          <option value="2">Two</option>
                          <option value="3">Three</option>
                        </select>
                </div>

                <div class="form-group">
                    <label for="content">Content</label>
                    <textarea name="content" id="content" required class="form-control" rows="5" placeholder="Content"></textarea>
                </div>

                <div class="form-group">
                    <label for="content">Status</label>
                        <select class="custom-select">
                          <option selected>Status</option>
                          <option value="1">One</option>
                          <option value="2">Two</option>
                          <option value="3">Three</option>
                        </select>
                </div>  
                
                <br>
                
                <input class="btn btn-success btn-lg btn-block" type="submit" value="Create post">
            </form>

jet started a new conversation Integrity Constraint Violation: 1048 Column 'category_id' Cannot Be Null (SQL: Insert Into `posts`

 public function store(Request $request)
    {
        $this->validate($request, array(
                'title' => 'required|max:255',
                
        ));

        $post = new Post;

        $post->title = $request->title;
        $post->category_id = $request->category_id;
        $post->content = $request->content;
        $post->order = $request->order;
        $post->views = $request->views;
        $post->status = $request->status;
        $post->slug  = str_slug($request->title);
        $post->meta = $request->meta;
        

        $post->save();

        return redirect()->route('posts.show', $post->id);
    }

how can i fix it

jet started a new conversation Call To Undefined Function Create()

this is the PostsTableSeeder

<?php

use Illuminate\Database\Seeder;

class PostsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        factory(App\Post::class, 30)-create();
    }
}
28 Nov
2 weeks ago

jet left a reply on Array_keys() Expects Parameter 1 To Be Array, Integer Given

I just clone a new project to start working with then that error came up

jet started a new conversation Array_keys() Expects Parameter 1 To Be Array, Integer Given

how can I fix that error?

26 Aug
3 months ago