nhayder
266
6
Laravel

Can't access seeder file from controller

Posted 3 months ago by nhayder

i have a test seeder stored on Database\seeds\TestSeeder.php. From a controller on my app im trying to run the seeder file like but i keep getting this error

message: "Class 'Database\Seeds\TestSeeder' not found",…}

this my controller

<?php

namespace App\Http\Controllers;

use Illuminate\Database\Seeder;
use Illuminate\Http\Request;
use App\Widget;
use cache;

use Illuminate\Support\Facades\DB;


class WidgetController extends Controller
{
    public function store(Request $request)
    {

        $seeder = new \Database\Seeds\TestSeeder();

        $seeder->run();
        
    }

}

this is my seeder file

<?php

use Illuminate\Database\Seeder;

class WidgetSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        DB::table('widgets')->insert([
            [
                'name' => 'intro-jumbotron',
                'user_name' => '',

                'dynamicbtn' => '0',
                'dynamicbtnurl' => 'javascript:void(0)',
                'cellmanagement' => '0',
                'fullscreendisabled' => '1',
                'showbuttonsdisabled' => '1',
                'showarrowdisabled' => '1',

                'page_id' => '1',
                'sorting' => '1',
           
                'fullscreen' => '0',
                'narrow' => '1',
                'pt' => 'pt-10',
                'pb' => 'pb-10',
                'mt' => '0',
                'mb' => '0',
                'mr' => '0',
                'ml' => '0',
            // -> list continues
            ]
        ]);
    }
}


any idea what is going on ??

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.