Khin Zin Zin Thinn

Member Since 1 Month Ago

Experience Points
2,860
Total
Experience

2,140 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
18
Lessons
Completed
Best Reply Awards
0
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.

  • Community Pillar

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

Level 1
2,860 XP
May
19
3 weeks ago
Activity icon

Started a new Conversation Swift_TransportException Connection Could Not Be Established With Host Smtp.gmail.com :stream_socket_client(): Unable To Connect To Ssl://smtp.gmail.com:465 (Network Is Unreachable)

Hello,

When I moved the project from localhost to cPanel, there is an error with the email as below. Please help me solve this. I have mentioned the codes from .env and mail.php below. Thanks.

.env file

MAIL_DRIVER = smtp
MAIL_HOST = smtp.gmail.com
MAIL_PORT = 465
MAIL_USERNAME = [email protected]
MAIL_PASSWORD = gjsqxziplyjwsmfe
MAIL_ENCRYPTION = ssl


mail.php

'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
            'port' => env('MAIL_PORT', 465),
            'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
        ],

"stream" => [
        'ssl' => [
                'allow_self_signed'=>true,
                'verify_peer'=>false,
                'verify_peer_name'=>false,
            ],
        ],

'from' => [
        'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
        'name' => env('MAIL_FROM_NAME', 'US AUTO'),
    ],
Activity icon

Started a new Conversation Carousel Show Only One Image

When I click quick veiw button on every product that I show through foreach, the modal appears. Inside the modal, there are product images . I want to show the images as carousel slide. But the slide show only one image and the next and previous buttons are not working well.

How can I solve this problem? Please suggest me . Thank you in advance. Have a nice day!

May
17
3 weeks ago
Activity icon

Started a new Conversation Image Must Be An Image

I have one problem with uploading image Validation. I uploaded valid format of image but the error said "Photo must be image."

THis is my validation.

'photos'=>'required| image',

This is my form.

<form method="post" action="{{route('new.product')}}" enctype="multipart/form-data">
                      @csrf

						<div class="col-md-9">
                                    <label for="photos"  class="col-form-label input-label">Upload Photo</label>
                                    <div class="custom-file">
                                    <input type="file" class="form-control input-label shadow @if($errors->has('photos'))is-invalid @endif" id="photos" name="photos[]" multiple value="{{old('photos')}}">
                                    @if($errors->has('photos'))<span class="invalid_feedback text-danger" style="font-size: 10px;">{{$errors->first('photos')}}</span> @endif
                                    </div>
                                </div>
</form>

Please help me to figure out this problem. Thank you in advance.

May
13
4 weeks ago
Activity icon

Started a new Conversation Use Maatwebsite\Excel\Concerns\WithHeadingRow Not Found

I am using Maatwebsite\Excel package to import excel file to database. It is fine to run in localhost. After running my project in C Panel, I got this error. use Maatwebsite\Excel\Concerns\WithHeadingRow not found

Please sugget me what should I do?

Here is my codes.

<?php

namespace App\Imports;

use Maatwebsite\Excel\Concerns\ToModel;
use App\Models\Product;
use Maatwebsite\Excel\Concerns\WithheadingRow;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ProcessUtils;
use Maatwebsite\Excel\Concerns\Importable;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\RegistersEventListeners;
use Maatwebsite\Excel\Events\BeforeImport;
use Image;
use Illuminate\Support\Facades\Auth;


class ProductsImport implements ToModel,WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */

    use Importable, RegistersEventListeners;

    
    public function model(array $row)
    {
			.......................
}
}
May
05
1 month ago
Activity icon

Started a new Conversation Swiper-bundle.min.js:13 Uncaught TypeError: Cannot Read Property '$el' Of Null

swiper-bundle.min.js:13 Uncaught TypeError: Cannot read property '$el' of null
    at t.init (swiper-bundle.min.js:13)
    at t.beforeInit (swiper-bundle.min.js:13)
    at swiper-bundle.min.js:13
    at Array.forEach (<anonymous>)
    at swiper-bundle.min.js:13
    at Array.forEach (<anonymous>)
    at t.emit (swiper-bundle.min.js:13)
    at t.r.init (swiper-bundle.min.js:13)
    at new t (swiper-bundle.min.js:13)
    at HTMLDivElement.<anonymous> (swiper-bundle.min.js:13)\

I got this error. I use bootstrap 5. Pls help me to solve.

May
02
1 month ago
Activity icon

Started a new Conversation No 'Access-Control-Allow-Origin' Header Is Present On The Requested Resource.

Access to XMLHttpRequest at 'https://www.google.com/cloudprint/invites?xsrf=&hl=en-US&client=chrome' from origin 'chrome://print' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Failed to load 
www.google.com/cloudprint/invites?xsrf=&hl=en-US&client=chrome:1  resource: net::ERR_FAILED

Hello, I am trying to print the invoice and I'm using

window.addEventListener("load", window.print()); This function.

But I got this error message in console . Can you help me to figure out this error? Thank you.

May
01
1 month ago
Activity icon

Replied to BadMethodCallException Method Illuminate\Routing\Route::with Does Not Exist.

I am adding custom html, css template to my project and just wanted to enable the logout button of it. I actually watched a tuto video on udemy that he does the same way but with no error. I also tried changing that to the 'post' method and it doesn't work. I included the route('login') inside redirect() and it still doesn't work. Please guide me what I should do next.

Activity icon

Started a new Conversation BadMethodCallException Method Illuminate\Routing\Route::with Does Not Exist.

I am now trying to create the log out button and this error pops up. I already spent some time on it and it is still not resolved. Please suggest to me what to do to solve this. Thanks. (FYI: I have installed the Jetstream for authentication)

Codes from Blade button

<li class="dropdown-footer">
    <a href="{{ route('user.logout') }}"> <i class="mdi mdi-logout"></i> Log Out </a>
</li>

Codes from Route

Route::get('/user/logout', [UserController::class, 'logout'])->with('user.logout');

Codes from Controller

<?php

namespace App\Http\Controllers;

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

class UserController extends Controller
{
    public function __construct() {
        $this->middleware(['auth']);
    }

    public function logout() {
        Auth::logout();

        return redirect()->route('login')->with('success', 'Logged Out');
    }
}
Activity icon

Started a new Conversation Adding Jquery To Voyager Package

I can't use jquery while using voyager Package. I want to wirte jquery scripts in blade but I don't know where add jquery . I add in master.blade.php and it doesn't work.

Apr
30
1 month ago
Activity icon

Replied to SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'image' In 'field List' (SQL: Insert Into `multimgs` (`image`, `updated_at`, `created_at`) Values (image/multimgs/1698482059909364.png, 2021-04-30 16:05:17, 2021-04-30 16:05:17))

Thanks for your answer. But I am doubtful that it would be a problem with the file upload since I am using the 'save()' method from the Intervention/Image.

Activity icon

Started a new Conversation SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'image' In 'field List' (SQL: Insert Into `multimgs` (`image`, `updated_at`, `created_at`) Values (image/multimgs/1698482059909364.png, 2021-04-30 16:05:17, 2021-04-30 16:05:17))

I am trying to upload multiple images. But ended up with this error. Please suggest me what to do next.

This is the Code from Controller

<?php

namespace App\Http\Controllers;

use App\Models\Multimg;
use Illuminate\Http\Request;
use Image;

class MultimgController extends Controller
{
    public function index() {
        $multimgs = Multimg::latest()->paginate(15);
        return view('admin.multimgs.index', compact('multimgs'));
    }

    public function store(Request $request) {

        $image = $request->file('image');

        foreach($image as $multimgs) {
            $img_name = hexdec(uniqid()).'.'.$multimgs->getClientOriginalExtension();
            $img_loca = 'image/multimgs/';
            Image::make($multimgs)->resize(300, 300)->save($img_loca.$img_name);
            $final_img = $img_loca.$img_name;

            $newMultimgs = new Multimg;
            $newMultimgs->image = $final_img;
            $newMultimgs->save();
        }

        return redirect()->back()->with('success', 'Images Have Been Added Successfully !');
    }
}

This is the Code from Model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Multimg extends Model
{
    use HasFactory;

    protected $fillable = ['image'];
}

This is the Code from Migration

public function up()
    {
        Schema::create('multimgs', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->timestamps();
        });
    }

This is the Code from Route

Route::get('/multimgs', [MultimgController::class, 'index'])->name('multimgs');
Route::post('/multimgs', [MultimgController::class, 'store'])->name('multimgs.store');

This is the Code from Blade

<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            Image Gallery
        </h2>
    </x-slot>

    <div class="container w-70">
        @if(session('success'))
            <div class="alert alert-success alert-dismissible fade show mt-5" role="alert">
                {{ session('success') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        @endif
    </div>
    <div class="row container mx-auto mt-5">
        <div class="col-md-8">
            {{-- Image Gallery --}}
            <div class="card">
                <div class="card-header">
                    Image Gallery
                </div>
                <div class="card-body">
                </div>
            </div>
        </div>
        <div class="col-md-4">
            {{-- Add Images --}}
            <div class="card">
                <div class="card-header">
                Add Images
                </div>
                <div class="card-body">
                    <form action="{{ route('multimgs.store') }}" method="post" enctype="multipart/form-data">
                        @csrf
                        <div class="mb-3 mt-2">
                            <input type="file" class="form-control" name="image[]" id="exampleInputEmail1" aria-describedby="emailHelp" multiple="">
                            @error('image')
                                <small class="text-danger mt-2">{{ $message }}</small>
                            @enderror
                        </div>
                        <button type="submit" class="btn btn-outline-secondary mb-2">Submit</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
    
    
</x-app-layout>```
Apr
29
1 month ago
Activity icon

Replied to N Attempt Was Made To Access A Socket In A Way Forbidden By Its Access Permissions.

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       11544
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       1156
  TCP    0.0.0.0:443            0.0.0.0:0              LISTENING       11544
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:1536           0.0.0.0:0              LISTENING       1000
  TCP    0.0.0.0:1537           0.0.0.0:0              LISTENING       828
  TCP    0.0.0.0:1538           0.0.0.0:0              LISTENING       1828
-- More  --

I run 'netstat -aon | more' command and it show active connections but I don't know what continue to do.

Activity icon

Started a new Conversation N Attempt Was Made To Access A Socket In A Way Forbidden By Its Access Permissions.

I run the command 'php artisan serve' and got this error . Help me to solve this. Thank you in advance.

Laravel development server started: http://127.0.0.1:8000
[Thu Apr 29 14:09:47 2021] Failed to listen on 127.0.0.1:8000 (reason: An attempt was made to access a socket in a way forbidden by its access permissions.
Apr
28
1 month ago
Activity icon

Started a new Conversation Sale Report Chart

Do you have any recommandation for sale report chart tutorial in laravel 7? Or Do you have any sample code?

Apr
27
1 month ago
Activity icon

Replied to Call To A Member Function Has() On String

Sure, all my view files are blade files.

Activity icon

Replied to Call To A Member Function Has() On String

I mean $errors->has(...) , In Login and register I use @error(---) and in other blade, I use @errors->has(---)

Activity icon

Started a new Conversation Call To A Member Function Has() On String

Call to a member function has() on string

I got this error in every $error->has('name') or @error('name')

In also Login and register blade, call to a member function getBag() error points to @error('name').

And, In console Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Please help me to figure out this problem. Thank you in advance.

Apr
26
1 month ago
Activity icon

Started a new Conversation Printing Page Error In Laravel

Access to XMLHttpRequest at 'https://www.google.com/cloudprint/invites?xsrf=&hl=en-US&client=chrome' from origin 'chrome://print' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
www.google.com/cloudprint/invites?xsrf=&hl=en-US&client=chrome:1 Failed to load resource: net::ERR_FAILED
print/:1 Access to XMLHttpRequest at 'https://www.google.com/cloudprint/search?xsrf=&hl=en-US&connection_status=ALL&client=chrome&use_cdd=true&q=%255Erecent' from origin 'chrome://print' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
www.google.com/cloudprint/search?xsrf=&hl=en-US&connection_status=ALL&client=chrome&use_cdd=true&q=%255Erecent:1 Failed to load resource: net::ERR_FAILED
print/:1 Access to XMLHttpRequest at 'https://www.google.com/cloudprint/search?xsrf=&hl=en-US&connection_status=ALL&client=chrome&use_cdd=true' from origin 'chrome://print' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
www.google.com/cloudprint/search?xsrf=&hl=en-US&connection_status=ALL&client=chrome&use_cdd=true:1 Failed to load resource: net::ERR_FAILED

I want to create A5 size printing. And i got this error. How to solve this?

Activity icon

Replied to Problem With Role And Permission

Thank you, This is the problem. I ordered wrong.

Activity icon

Replied to Problem With Role And Permission

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        // $this->call(UsersTableSeeder::class);
        $this->call(CreateAdminUserSeeder::class);
        $this->call(PermissionTableSeeder::class);
    }
Activity icon

Replied to Problem With Role And Permission

Which file should I show to you? Model or Controller or migration?

Activity icon

Replied to Problem With Role And Permission

<?php

use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use App\User;


class CreateAdminUserSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $user = User::create([
        	'name' => 'Aim Aim', 
            'phone'=>'09784126995',
        	'email' => '[email protected]',
        	'password' => bcrypt('123456')
        ]);
  
        $role = Role::create(['name' => 'Admin']);
   
        $permissions = Permission::pluck('id','id')->all();
  
        $role->syncPermissions($permissions);
   
        $user->assignRole([$role->id]);
    }
}

This is My Seeder

Activity icon

Started a new Conversation Problem With Role And Permission

I have problem with Role. I use Spatie Package for assign role and permission. When I run with seed table, user and permissions can create but cannot join role, permission and user. What can be the problem. I don't know how to solve. Please help me to figure out.

Activity icon

Replied to Call To Undefined Method App\User::setRole()

Thank you, i got it. I just delete vendor folder and composer.lock and run composer install as you said. Thank you so much.

Activity icon

Replied to Call To Undefined Method App\User::setRole()

I think the problem is in #2 . I used tcg\voyager and removed it. Can I remove this folder from vendor.?

Activity icon

Replied to Call To Undefined Method App\User::setRole()

[2021-04-26 08:02:01] local.ERROR: Call to undefined method App\User::setRole() {"exception":"[object] (BadMethodCallException(code: 0): Call to undefined method App\User::setRole() at C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php:50)
[stacktrace]
#0 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php(36): Illuminate\Database\Eloquent\Model::throwBadMethodCallException('setRole')
#1 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1736): Illuminate\Database\Eloquent\Model->forwardCallTo(Object(Illuminate\Database\Eloquent\Builder), 'setRole', Array)
#2 C:\xampp\htdocs\htdocs\usauto\vendor\tcg\voyager\src\VoyagerServiceProvider.php(106): Illuminate\Database\Eloquent\Model->__call('setRole', Array)
#3 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php(381): TCG\Voyager\VoyagerServiceProvider->TCG\Voyager\{closure}(Object(App\User))
#4 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Events\Dispatcher.php(226): Illuminate\Events\Dispatcher->Illuminate\Events\{closure}('eloquent.create...', Array)
#5 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasEvents.php(189): Illuminate\Events\Dispatcher->dispatch('eloquent.create...', Array)
#6 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(888): Illuminate\Database\Eloquent\Model->fireModelEvent('created', false)
#7 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(730): Illuminate\Database\Eloquent\Model->performInsert(Object(Illuminate\Database\Eloquent\Builder))
#8 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php(776): Illuminate\Database\Eloquent\Model->save()
#9 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Support\helpers.php(433): Illuminate\Database\Eloquent\Builder->Illuminate\Database\Eloquent\{closure}(Object(App\User))
#10 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php(777): tap(Object(App\User), Object(Closure))
#11 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php(23): Illuminate\Database\Eloquent\Builder->create(Array)
#12 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1736): Illuminate\Database\Eloquent\Model->forwardCallTo(Object(Illuminate\Database\Eloquent\Builder), 'create', Array)
#13 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php(1748): Illuminate\Database\Eloquent\Model->__call('create', Array)
#14 C:\xampp\htdocs\htdocs\usauto\database\seeds\CreateAdminUserSeeder.php(22): Illuminate\Database\Eloquent\Model::__callStatic('create', Array)
#15 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): CreateAdminUserSeeder->run()
#16 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\Util.php(37): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#17 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#18 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#19 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\Container.php(596): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#20 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Seeder.php(134): Illuminate\Container\Container->call(Array)
#21 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Seeder.php(48): Illuminate\Database\Seeder->__invoke()
#22 C:\xampp\htdocs\htdocs\usauto\database\seeds\DatabaseSeeder.php(15): Illuminate\Database\Seeder->call('CreateAdminUser...')
#23 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): DatabaseSeeder->run()
#24 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\Util.php(37): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#25 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#26 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#27 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\Container.php(596): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#28 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Seeder.php(134): Illuminate\Container\Container->call(Array)
#29 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Console\Seeds\SeedCommand.php(65): Illuminate\Database\Seeder->__invoke()
#30 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\GuardsAttributes.php(155): Illuminate\Database\Console\Seeds\SeedCommand->Illuminate\Database\Console\Seeds\{closure}()
#31 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Console\Seeds\SeedCommand.php(66): Illuminate\Database\Eloquent\Model::unguarded(Object(Closure))
#32 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(36): Illuminate\Database\Console\Seeds\SeedCommand->handle()
#33 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\Util.php(37): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#34 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
#35 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#36 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Container\Container.php(596): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#37 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Console\Command.php(134): Illuminate\Container\Container->call(Array)
#38 C:\xampp\htdocs\htdocs\usauto\vendor\symfony\console\Command\Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#39 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Console\Command.php(121): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#40 C:\xampp\htdocs\htdocs\usauto\vendor\symfony\console\Application.php(971): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#41 C:\xampp\htdocs\htdocs\usauto\vendor\symfony\console\Application.php(290): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Seeds\SeedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#42 C:\xampp\htdocs\htdocs\usauto\vendor\symfony\console\Application.php(166): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#43 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Console\Application.php(93): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#44 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(129): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#45 C:\xampp\htdocs\htdocs\usauto\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#46 {main}
"}

Activity icon

Replied to Call To Undefined Method App\User::setRole()

php artisan db:seed
Seeding: CreateAdminUserSeeder

   BadMethodCallException 

  Call to undefined method App\User::setRole()

  at C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php:50
    46|      * @throws \BadMethodCallException
    47|      */
    48|     protected static function throwBadMethodCallException($method)
    49|     {
  > 50|         throw new BadMethodCallException(sprintf(
    51|             'Call to undefined method %s::%s()', static::class, $method
    52|         ));
    53|     }
    54| }

  • Bad Method Call: Did you mean App\User::scopeRole() ? 

  1   C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php:36
      Illuminate\Database\Eloquent\Model::throwBadMethodCallException("setRole")

  2   C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1736
      Illuminate\Database\Eloquent\Model::forwardCallTo(Object(Illuminate\Database\Eloquent\Builder), "setRole")

THis is error . I didn't use setRole(), I just use assignRole(). Either setRole() or assignRole(), the error is the same.

Activity icon

Replied to Call To Undefined Method App\User::setRole()

use Illuminate\Database\Seeder; use Spatie\Permission\Models\Role; use Spatie\Permission\Models\Permission; use App\User;

class CreateAdminUserSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { $user = User::create([ 'name' => 'Ai Ai', 'phone'=>'09784126995', 'email' => '[email protected]', 'password' => bcrypt('123456') ]);

    $role = Role::create(['name' => 'Admin']);

    $permissions = Permission::pluck('id','id')->all();

    $role->syncPermissions($permissions);

    $user->assignRole([$role->id]);
}

}

Activity icon

Replied to Call To Undefined Method App\User::setRole()

namespace App; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable { use Notifiable, HasRoles; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'phone', 'email', 'password', ];

/**
 * The attributes that should be hidden for arrays.
 *
 * @var array
 */
protected $hidden = [
    'password', 'remember_token',
];

/**
 * The attributes that should be cast to native types.
 *
 * @var array
 */
protected $casts = [
    'email_verified_at' => 'datetime',
];

}

Activity icon

Replied to Call To Undefined Method App\User::setRole()

Spatie package for roles and permissions

Activity icon

Replied to Call To Undefined Method App\User::setRole()

This is my code and I didn't use setRole()

Activity icon

Replied to Call To Undefined Method App\User::setRole()

This is my code in CreateAdminUserSeeder

Activity icon

Started a new Conversation Call To Undefined Method App\User::setRole()

I run php artisan db:seed and I got this error. PS C:\xampp\htdocs\htdocs\usauto> php artisan db:seed Seeding: CreateAdminUserSeeder

BadMethodCallException

Call to undefined method App\User::setRole()

at C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php:50 46| * @throws \BadMethodCallException 47| */ 48| protected static function throwBadMethodCallException($method) 49| {

50| throw new BadMethodCallException(sprintf( 51| 'Call to undefined method %s::%s()', static::class, $method 52| )); 53| } 54| }

• Bad Method Call: Did you mean App\User::scopeRole() ?

1 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Support\Traits\ForwardsCalls.php:36 Illuminate\Database\Eloquent\Model::throwBadMethodCallException("setRole")

2 C:\xampp\htdocs\htdocs\usauto\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php:1736 Illuminate\Database\Eloquent\Model::forwardCallTo(Object(Illuminate\Database\Eloquent\Builder), "setRole") PS C:\xampp\htdocs\htdocs\usauto>

Apr
23
1 month ago
Activity icon

Started a new Conversation Call To A Member Function GetBag() On String

Hello!

First, I added 'phone' field in register file and I could register successfully. And, I want to login with phone number instead of email. So, I did as this instruction-> https://www.laravelcode.com/post/laravel-55-login-with-only-mobile-number-using-laravel-custom-auth And, I deleted User.php and users migrations file and re-created them. And I got this error .

Call to a member function getBag() on string (View: C:\xampp\htdocs\htdocs\project-name\resources\views\auth\register.blade.php)

Now, I deleted Auth files and reinstall Auth, But I still got this error. Please, Help me