tomasosho

tomasosho

CEO at TAP ventures & Edar Tech

Member Since 1 Year Ago

Abuja

Experience Points
8,470
Total
Experience

1,530 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
2
Lessons
Completed
Best Reply Awards
1
Best Reply
Awards
  • start your 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-in-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 Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist 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.

Level 2
8,470 XP
Oct
16
4 days ago
Activity icon

Replied to Request Method: GET Status Code: 500 Internal Server Error

It's not reflecting in the Logs

Activity icon

Replied to Request Method: GET Status Code: 500 Internal Server Error

public function addToCart(Request $request){
        $inputToCart=$request->all();
        // dd($inputToCart['products_id']);
        Session::forget('discount_amount_price');
        Session::forget('coupon_code');
        if($inputToCart['size']==""){
            return back()->with('message','Please select Size');
        }else{
            $inputToCart=$request->all();
            //dd(DB::table('product_attrs')->select('stock','sku')->where(['products_id' => $inputToCart['products_id'], 'price'=>$inputToCart['price']])->first());
            $stockAvailable=DB::table('product_attrs')->select('stock','sku')->where(['products_id' => $inputToCart['products_id'],
                'price'=>$inputToCart['price']])->first();
                dd($stockAvailable);
            if($stockAvailable->stock>=$inputToCart['quantity']){
                $inputToCart['user_email']='[email protected]';
                $session_id=Session::get('session_id');
                if(empty($session_id)){
                    $session_id=str_random(40);
                    Session::put('session_id',$session_id);
                }
                $inputToCart['session_id']=$session_id;
                $sizeAtrr=explode("-",$inputToCart['size']);
                $inputToCart['size']=$sizeAtrr[1];
                $inputToCart['product_code']=$stockAvailable->sku;
                $count_duplicateItems=Cart_model::where(['products_id'=>$inputToCart['products_id'],
                    'product_color'=>$inputToCart['product_color'],
                    'size'=>$inputToCart['size']])->count();
                if($count_duplicateItems>0){
                    return back()->with('message','This Item Added already');
                }else{
                    Cart_model::create($inputToCart);
                    return back()->with('message','Add To Cart Already');
                }
            }else{
                return back()->with('message','Stock is not Available!');
            }
        }
    }
Activity icon

Started a new Conversation Request Method: GET Status Code: 500 Internal Server Error

<form action="{{route('addToCart')}}" class="contact-form" method="post" role="form">
      {{ csrf_field() }}
<span id="dynamic_price">NGN {{ number_format($detail_product->price, 2) }}</span>

<select name="size" id="idSize" class="form-control" style="width: fit-content; margin-right: auto;">
            <option value="">Select Size</option>
              @foreach($detail_product->attributes as $attrs)
                  <option value="{{$detail_product->id}}-{{$attrs->size}}">{{$attrs->size}}</option>
              @endforeach
          </select>
</form>
Activity icon

Replied to SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column '0' In 'where Clause' (SQL: Select `stock`, `sku` From `product_attrs` Where (`0` = Products_id))

It's from a form

$inputToCart=$request->all();

dd(DB::table('product_attrs')->select('stock','sku')->where(['products_id' => $inputToCart['products_id'], 'price'=>$inputToCart['price']])->first());
Activity icon

Replied to SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column '0' In 'where Clause' (SQL: Select `stock`, `sku` From `product_attrs` Where (`0` = Products_id))

This is my full query, and i'm getting null

dd(DB::table('product_attrs')->select('stock','sku')->where(['products_id' => $inputToCart['products_id'],
            'price'=>$inputToCart['price']])->first());
Activity icon

Started a new Conversation SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column '0' In 'where Clause' (SQL: Select `stock`, `sku` From `product_attrs` Where (`0` = Products_id))

dd(DB::table('product_attrs')->select('stock','sku')->where(['products_id'])->get());

DB

Schema::create('product_attrs', function (Blueprint $table) {
            $table->id();
            $table->integer('products_id')->nullable();
            $table->string('sku')->nullable();
            $table->string('size')->nullable();
            $table->float('price')->nullable();
            $table->integer('stock')->nullable();
            $table->string('image')->nullable();
            $table->string('image2')->nullable();
            $table->string('image3')->nullable();
            $table->string('video')->nullable();
            $table->timestamps();
        });
Oct
14
6 days ago
Activity icon

Replied to LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

I am getting null

    public function show($profile)
    {
        dd(User::find($profile));
        return view('user.vendor-profile', compact('profile'));
    }

link

http://127.0.0.1:8000/vendor-profile/vendor123

Route

Route::resource('vendor-profile', 'VendorController');
Activity icon

Replied to LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

App\User {#1323 ▼
  #fillable: array:18 [▶]
  #hidden: array:2 [▶]
  #casts: array:1 [▶]
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #classCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #visible: []
  #guarded: array:1 [▶]
  #rememberTokenName: "remember_token"
}

Still the same 😭

Activity icon

Replied to LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

Same thing

LogicException
Route pattern "/profiless/{sl}/{{sl}}" cannot reference variable name "sl" more than once.
http://127.0.0.1:8000/vendor-profile/vendor123

Controller Profile

public function show(User $sl)
    {
        return view('user.profile-index', compact('sl'));
    }

Controller Vendor

public function show(User $sl)
    {
        return view('user.vendor-profile', compact('sl'));
    }

Route

// User Profile
Route::resource('profiless/{sl}', 'ProfileController');

// Vendor Profile
Route::resource('vendor-profile/{slug}', 'VendorController');

// Agent Profile
Route::resource('agent-profile/{slug}', 'AgentController');
Activity icon

Replied to LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

// User Profile
Route::resource('profiles/{profile}', 'ProfileController');

// Vendor Profile
Route::resource('vendor-profile/{profile}', 'VendorController');

// Agent Profile
Route::resource('agent-profile/{profile}', 'AgentController');

I am running vendor-profile/{profile}, it's giving me the error. if i remove

// User Profile
Route::resource('profiles/{profile}', 'ProfileController');

it runs smoothly.

Same thing applies to

// Vendor Profile
Route::resource('vendor-profile/{profile}', 'VendorController');

and

I am running ```vendor-profile/{profile}```, it's giving me the error.
if i remove 
Activity icon

Replied to LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

Do i get to replace the {slug} in the route with {profile} too?

If i don't use the {profile} it's empty and if i use the {profile}, i get that error.

Activity icon

Replied to LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

Symfony\Component\Routing\RouteCompiler::compilePattern
vendor/symfony/routing/RouteCompiler.php:149

NOTE: I only get the error message when i include /{slug} in my web route

Activity icon

Replied to LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

Empty

App\User {#1339 ▼
  #fillable: array:18 [▶]
  #hidden: array:2 [▶]
  #casts: array:1 [▶]
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #classCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #visible: []
  #guarded: array:1 [▶]
  #rememberTokenName: "remember_token"
}
Activity icon

Replied to LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

No i did not,

All i did was user slug as my keyname in my user model

public function getRouteKeyName()
    {
        return 'slug';
    }

When i use this Route::resource('profile', 'ProfileController');, my user properties does not appear, and i'm not trying to use Auth::user()->property

Activity icon

Started a new Conversation LogicException Route Pattern "/profile/{slug}/{{slug}}" Cannot Reference Variable Name "slug" More Than Once.

I've been getting this error

LogicException Route pattern "/profile/{slug}/{{slug}}" cannot reference variable name "slug" more than once.

Routes

// User Profile
Route::resource('profile/{slug}', 'ProfileController');

// Vendor Profile
Route::resource('vendor-profile/{slug}', 'VendorController');

// Agent Profile
Route::resource('agent-profile/{slug}', 'AgentController');

Controller

/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(User $slug)
    {
        return view('user.profile-index', compact('slug'));
    }
Oct
10
1 week ago
Activity icon

Replied to How To Relanships To Table ?

let's see your form, or simply dd($request->country_id);

Activity icon

Replied to How To Upload Multiple Image In A Single Row?

a little more detail will do

Activity icon

Replied to SQLITE Database Throw Error Could Not Find Driver (SQL: PRAGMA Foreign_keys = ON;)

It's best to use full SQL rather than SQLite. SQLite increases exponentially in size.

Oct
08
1 week ago
Activity icon

Replied to I Have A Products Table With A Row For Category_id And A Category Table With Id.

i used. this return $this->hasMany('App\Models\Comment', 'foreign_key', 'local_key'); in the model and it worked.

public function products()
    {
        return $this->hasMany(Product::class, 'categories_id', 'id');
    }
Activity icon

Started a new Conversation I Have A Products Table With A Row For Category_id And A Category Table With Id.

Category Model

public function products()
    {
        return $this->hasMany(Product::class, 'category_id');
    }

Product Model

public function category()
    {
        return $this->belongsTo('App\Models\ProductCategory');
    }

Controller

$products = Category::inRandomOrder('id')->products->limit(4);

i have a products table with a row for category_id and a category table with id.

Error

i have a products table with a row for category_id and a category table with id.
Activity icon

Replied to I Want To List Categories Randomly And List Products

Category Model

public function products()
    {
        return $this->hasMany(Product::class, 'category_id');
    }

Product Model

public function category()
    {
        return $this->belongsTo('App\Models\ProductCategory');
    }

Controller

$products = Category::inRandomOrder('id')->products->limit(4);

i have a products table with a row for category_id and a category table with id.

Error

i have a products table with a row for category_id and a category table with id.

@automica

Activity icon

Replied to I Want To List Categories Randomly And List Products

i have a products table with a row for category_id and a category table with id. That's my structure, i was just trying to limit the render to 4 thats why was using the pagination.

@tykus

Activity icon

Replied to I Want To List Categories Randomly And List Products

Category Model

public function products()
    {
        return $this->hasMany(Product::class, 'category_id');
    }

Product Model

public function category()
    {
        return $this->belongsTo('App\Models\ProductCategory');
    }

Controller still the same still getting sam error

Activity icon

Replied to I Want To List Categories Randomly And List Products

what's the suggested solution? @tykus

Activity icon

Replied to I Want To List Categories Randomly And List Products

i made an error it wasn't in the table

Updated model

public function products()
    {
        return $this->belongsToMany(Product::class, 'category_id');
    }

updated controller

$products = Category::inRandomOrder('id')->products->paginate(4);
Activity icon

Replied to I Want To List Categories Randomly And List Products

i keep getting

Exception
Property [products] does not exist on the Eloquent builder instance.
Activity icon

Started a new Conversation I Want To List Categories Randomly And List Products

Category model

public function products()
{
    return $this->belongsToMany(Product::class);
}

Controller

public function index()
  {
    $products = Category::inRandomOrder('category_id')->products->->paginate(4);

    return view('shop', compact('products'));
  }
Oct
04
2 weeks ago
Activity icon

Replied to ErrorException Undefined Variable: FileNameToStore

grateful, i just totally overlooked that 😭

Activity icon

Replied to ErrorException Undefined Variable: FileNameToStore

when i get to dd($request->input('image')); it returns my image name, but when i dd($request->hasFile('image')); it fails.

Activity icon

Started a new Conversation ErrorException Undefined Variable: FileNameToStore

View

<form class="input-form" action="{{ route('slider.store') }}" method="POST">
                    {{ csrf_field() }}
                    <label class="control-label mt-3" for="example-input1-group2">New Slider</label>
                    <div class="row">
                        <div class="col-lg-4">
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <label class="btn btn-danger" type="button">Upload Image</label>
                                </div>
                                <input type="file" class="form-control" name="image" accept="image/*">
                            </div>
                        </div>
                        <div class="col-md-4 mb-3 mb-md-0">
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <label class="btn btn-info">Text</label>
                                </div>
                                <input type="text" name="text" class="form-control" placeholder="Enter your text here...">
                            </div>
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-lg-12">
                            <button type="submit" class="btn btn-primary">Save</button>
                        </div>
                    </div>
                    <!-- form-group -->
                </form>

Controller

public function store(Request $request)
    {
        // dd($request->input('image'));
        $data = request()->validate([
            'image' => 'required',
        ]);

        // Handle File Upload
        if($request->hasFile('image')){
            // Get filename with the extension
            $filenameWithExt = $request->file('image')->getClientOriginalName();
            // Get just filename
            $filename = pathinfo($filenameWithExt, PATHINFO_FILENAME);
            // Get just ext
            $extension = $request->file('image')->getClientOriginalExtension();
            // Filename to store
            $fileNameToStore= $filename.'_'.time().'.'.$extension;
            // Upload Image
            $path = $request->file('image')->storeAs('public/slider', $fileNameToStore);
        }
        

        $slider = new Slider;
        $slider->image = $fileNameToStore;
        $slider->text = $request->input('text');
        $slider->save();
        return back()->with('success', 'Saved Successfully');
    }
Oct
02
2 weeks ago
Activity icon

Replied to Undefined Variable: Header (Laravel 8)

It has the variable. when i delete it, i get same error for $slot and when i delete slot. I get an empty view

Activity icon

Replied to Undefined Variable: Header (Laravel 8)

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:[email protected];600;700&display=swap">

        <!-- Styles -->
        <link rel="stylesheet" href="{{ asset('css/app.css') }}">

        @livewireStyles

        <!-- Scripts -->
        <script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.js" defer></script>
    </head>
    <body class="font-sans antialiased">
        <div class="min-h-screen bg-gray-100">
            @livewire('navigation-dropdown')

            <!-- Page Heading -->
            <header class="bg-white shadow">
                <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
                    {{ $header }}
                </div>
            </header>

            <!-- Page Content -->
            <main>
                {{ $slot }}
            </main>
        </div>

        @stack('modals')

        @livewireScripts
    </body>
</html>
Activity icon

Started a new Conversation Undefined Variable: Header (Laravel 8)

How can i fix this?

@extends('layouts.app')

@section('content')

<div class="container">
    @if ($message = Session::get('success'))
        <div class="alert alert-success">
            <p>{{ $message }}</p>
        </div>
        @endif
        @if ($errors->any())
        <div class="alert alert-danger">
            <strong>Opps!</strong> Something went wrong<br>
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    @extends('layouts.app')

@section('content')
<div class="container">
    @if ($message = Session::get('success'))
        <div class="alert alert-success">
            <p>{{ $message }}</p>
        </div>
        @endif
        @if ($errors->any())
        <div class="alert alert-danger">
            <strong>Opps!</strong> Something went wrong<br>
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    <div class="row justify-content-center mt40">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header"><h3>Edit</h3></div>
                <div class="card-body">
                @foreach ($home as $home)
                    <form action="{{ route('home.update', $home->id) }}" method="POST" name="add">
                        {{ csrf_field() }}
                        @method('PATCH')
                    
                        <div class="row">
                        <h2>Home Page</h2>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <strong>{{$home->number_1}}</strong>
                                    <input type="text" name="number_1" class="form-control" value="{{$home->number_1}}">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <strong>{{$home->text_1}}</strong>
                                    <input type="text" name="text_1" class="form-control" value="{{$home->text_1}}">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <strong>{{$home->text_1_2}}</strong>
                                    <input type="text" name="text_1_2" class="form-control" value="{{$home->text_1_2}}">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <strong>{{$home->text_1_3}}</strong>
                                    <input type="text" name="text_1_3" class="form-control" value="{{$home->text_1_3}}">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <img src="{{$home->picture_1}}" alt="">
                                    <input type="file" name="picture_1" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <strong>{{$home->text_1_1}}</strong>
                                    <input type="text" name="text_1_1" class="form-control" value="{{$home->text_1_1}}">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <strong>{{$home->number_2}}</strong>
                                    <input type="text" name="number_2" class="form-control" value="{{$home->number_2}}">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                <strong>{{$home->text_2}}</strong>
                                    <input type="text" name="text_2" class="form-control" value="{{$home->text_2}}">
                                </div>
                            </div>
                            <div class="col-md-5">
                                <div class="form-group">
                                <strong>{{$home->text_2_2}}</strong>
                                    <input type="text" name="text_2_2" class="form-control" value="{{$home->text_2_2}}">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_2_3}}</strong>
                                    <input type="text" name="text_2_3" class="form-control" value="{{$home->text_2_3}}">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <img src="{{$home->icon_1}}" alt="">
                                    <input type="file" name="icon_1" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_1_}}</strong>
                                    <input type="text" name="text_1_" class="form-control" value="{{$home->text_1_}}">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <img src="{{$home->icon_2}}" alt="">
                                    <input type="file" name="icon_2" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_2_}}</strong>
                                    <input type="text" name="text_2_" class="form-control" value="{{$home->text_2_}}">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <img src="{{$home->icon_3}}" alt="">
                                    <input type="file" name="icon_3" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_3}}</strong>
                                    <input type="text" name="text_3" class="form-control" value="{{$home->text_3}}">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <img src="{{$home->icon_4}}" alt="">
                                    <input type="file" name="icon_4" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_4}}</strong>
                                    <input type="text" name="text_4" class="form-control" value="{{$home->text_4}}">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <img src="{{$home->icon_5}}" alt="">
                                    <input type="file" name="icon_5" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_5}}</strong>
                                    <input type="text" name="text_5" class="form-control" value="{{$home->text_5}}">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->number_3}}</strong>
                                    <input type="text" name="number_3" class="form-control" value="{{$home->number_3}}">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_3_}}</strong>
                                    <input type="text" name="text_3_" class="form-control" value="{{$home->text_3_}}">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_3_2}}</strong>
                                    <input type="text" name="text_3_2" class="form-control" value="{{$home->text_3_2}}">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->text_3_3}}</strong>
                                    <input type="text" name="text_3_3" class="form-control" value="{{$home->text_3_3}}">
                                </div>
                            </div>
                            <h2>Mission Statement</h2>
                            <div class="col-md-7">
                                <div class="form-group">
                                    <img src="{{$home->mission_image}}" alt="">
                                    <input type="file" name="mission_image" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->mission}}</strong>
                                    <input type="text" name="mission" class="form-control" value="{{$home->mission}}">
                                </div>
                            </div>
                            <h2>Vision Statement</h2>
                            <div class="col-md-7">
                                <div class="form-group">
                                    <img src="{{$home->vision_image}}" alt="">
                                    <input type="file" name="vision_image" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->vision}}</strong>
                                    <input type="text" name="vision" class="form-control" value="{{$home->vision}}">
                                </div>
                            </div>
                            <h2>Mandate</h2>
                            <div class="col-md-7">
                                <div class="form-group">
                                    <img src="{{$home->mandate_image}}" alt="">
                                    <input type="file" name="mandate_image" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->mandate}}</strong>
                                    <input type="text" name="mandate" class="form-control" value="{{$home->mandate}}">
                                </div>
                            </div>
                            <h2>Secretary</h2>
                            <div class="col-md-7">
                                <div class="form-group">
                                    <img src="{{$home->secretary_image}}" alt="">
                                    <input type="file" name="secretary_image" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->secretary_text}}</strong>
                                    <input type="text" name="secretary_text" class="form-control" value="{{$home->secretary_text}}">
                                </div>
                            </div>
                            <h2>Chairman</h2>
                            <div class="col-md-7">
                                <div class="form-group">
                                    <img src="{{$home->chairman_image}}" alt="">
                                    <input type="file" name="chairman_image" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group">
                                <strong>{{$home->chairman_text}}</strong>
                                    <input type="text" name="chairman_text" class="form-control" value="{{$home->chairman_text}}">
                                </div>
                            </div>
                            <div class="col-md-12">
                                    <button type="submit" class="btn btn-primary">Submit</button>
                            </div>
                        </div>
                                    
                    </form>
                @endforeach
                </div>
            </div>
        </div>
    <div>
</div>

@endsection

</div>

@endsection
Sep
16
1 month ago
Activity icon

Awarded Best Reply on ErrorException Creating Default Object From Empty Value

Made $slug primaryKey and set keyType as string

/**
     * Get the route key for the model.
     *
     * @return string
     */
    public function getRouteKeyName()
    {
        return 'slug';
    }

    // Table Name
    protected $table = 'product_categories';
    // Primary Key
    public $primaryKey = 'slug';
    // Primary Key Type
    public $keyType = 'string';
    // Timestamps
    public $timestamps = true;
Activity icon

Replied to ErrorException Creating Default Object From Empty Value

Made $slug primaryKey and set keyType as string

/**
     * Get the route key for the model.
     *
     * @return string
     */
    public function getRouteKeyName()
    {
        return 'slug';
    }

    // Table Name
    protected $table = 'product_categories';
    // Primary Key
    public $primaryKey = 'slug';
    // Primary Key Type
    public $keyType = 'string';
    // Timestamps
    public $timestamps = true;
Activity icon

Replied to ErrorException Creating Default Object From Empty Value

my slug is displaying 0 as value, instead of the original value in index and other pages

Activity icon

Replied to ErrorException Creating Default Object From Empty Value

Route::resource('productcategory', 'ProductCategoryController')->middleware('auth');
Activity icon

Started a new Conversation ErrorException Creating Default Object From Empty Value

My controller

public function update(Request $request, $slug)

    {

        $request->validate([

            'name' => 'required',

        ]);

 

        // dd($slug);

 

        $category = ProductCategory::find($slug);

        $category->name = $request->input('name');

        $category->description = $request->input('description');

        $category->status = $request->input('status');

        $category->save();

        return redirect('category')->with('success','Great! updated successfully.');

    }

My slug value is null i don't know why

My Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;

class ProductCategory extends Model
{
    use Sluggable;

    /**
     * Return the sluggable configuration array for this model.
     *
     * @return array
     */
    public function sluggable()
    {
        return [
            'slug' => [
                'source' => 'name'
            ]
        ];
    }

    public function getRouteKeyName()
    {
        return 'slug';
    }

    // Table Name
    protected $table = 'product_categories';
    // Primary Key
    public $primaryKey = 'slug';
    // Timestamps
    public $timestamps = true;
}
Sep
13
1 month ago
Activity icon

Started a new Conversation 419 Page Expired For Login

i am running my laravel app on a mac OS pc

in my header

<meta name="csrf-token" content="{{ csrf_token() }}">

in my script

<script>
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
    </script>

in my form

@csrf