irankhosravi

irankhosravi

Member Since 1 Year Ago

Experience Points 16,410
Experience Level 4

3,590 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 1
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

15 Sep
2 days ago

irankhosravi started a new conversation Column Not Found: 1054 Unknown Column '_method' In 'field List'

I want to update a faq form. but I get this error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column '_method' in 'field list' (SQL: update faqs set _method = PUT, _token = Kz2Wkgd44UA3nOVzmE8PhCGH66ywP296UqUQR8m6, title = q, body =

q

, faqs.updated_at = 2019-09-15 18:55:06 where faqs.user_id = 1 and faqs.user_id is not null)

FaqController.php

public function update(FaqRequest $request, Faq $faq)
{
    auth()->user()->faq()->update($request->all());
    return redirect()->route('faq.index');
}

edit.blade.php

<form action="{{ route('faq.update', $faq->id ) }}" method="post">
    @method('PUT')
    @csrf
    @include('errors.validate')
    <div class="form-group">
        <label for="title">title</label>
        <input type="text" class="form-control col-md-3" id="title" name="title" placeholder="عنوان" value="{{ old('title') ? : $faq->title }}">
    </div>
    <div class="form-group">
        <label for="body">body</label>
        <textarea class="form-control" rows="10" id="body" name="body">{{ old('body')  ? : $faq->body }}</textarea>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-primary">save</button>
    </div>
</form>

User.php

public function faq()
{
    return $this->hasMany(Faq::class);
}
02 Sep
2 weeks ago

irankhosravi started a new conversation How To Migrate A Table

I tried migrate a products table but I do not successfully. I get this error.

table

products table :

public function up()
{
    Schema::create('products', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->bigInteger('user_id')->unsigned();
        $table->bigInteger('customer_id')->unsigned();
        $table->string('title');
        $table->string('file');
        $table->text('body');
        $table->string('price');
        $table->string('slug');
        $table->string('image');
        $table->timestamps();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        $table->foreign('customer_id')->references('id')->on('users')->onDelete('cascade');
    });
}
26 Aug
3 weeks ago

irankhosravi left a reply on Route [] Not Defined.

I changed it with Route::group(['namespace' => 'Auth'], function () { but my problem did not solve yet.

I get Route [] not defined. error .

irankhosravi started a new conversation Route [] Not Defined.

What is this error?

error

web.php

 Route::group([], function () {
    // Authentication Routes...
    Route::get('login', 'Auth\[email protected]')->name('login');
    Route::post('login', 'Auth\[email protected]');
    Route::post('logout', 'Auth\[email protected]')->name('logout');

    // Registration Routes...
    if ($options['register'] ?? true) {
        Route::get('register', 'Auth\[email protected]')->name('register');
        Route::post('register', 'Auth\[email protected]');
    }

    // Registration Routes...
    if ($options['marketing'] ?? true) {
        Route::get('marketing', 'Auth\[email protected]')->name('marketing');
        Route::post('marketing', 'Auth\[email protected]');
    }

    // Password Reset Routes...
    if ($options['reset'] ?? true) {
        Route::get('password/reset', 'Auth\[email protected]')->name('password.request');
        Route::post('password/email', 'Auth\[email protected]')->name('password.email');
        Route::get('password/reset/{token}', 'Auth\[email protected]')->name('password.reset');
        Route::post('password/reset', 'Auth\[email protected]')->name('password.update');
    }

    // Email Verification Routes...
    if ($options['verify'] ?? false) {
        Route::get('email/verify', 'Auth\[email protected]')->name('verification.notice');
        Route::get('email/verify/{id}', 'Auth\[email protected]')->name('verification.verify');
        Route::get('email/resend', 'Auth\[email protected]')->name('verification.resend');
    }
});

register.blade.php

<form method="POST" action="{{ route('register') }}" enctype="multipart/form-data">
14 Aug
1 month ago

irankhosravi left a reply on How To Dispay Sweet Alert ?

@wilk_randall - What are you talking about?

13 Aug
1 month ago

irankhosravi left a reply on How To Dispay Sweet Alert ?

How to dispay sweet alert ?

irankhosravi started a new conversation How To Dispay Sweet Alert ?

I want to make a condition to show if there is anyone in the database. Show sweet alert if not available

My Controller.php

public function document(Request $request)
{
    $keyword = $request->input('code');
    $documents = Document::document($keyword)->latest()->get();
    if (!isset($documents)) {
        alert()->error('Information with this number has not been disclosed to the system.', 'ok')->persistent('ok');
    }
    return view('Home.content.documents', compact('documents'));
}
11 Aug
1 month ago
10 Aug
1 month ago

irankhosravi started a new conversation How To Search Code In Laravel

I want to search code for enter an admin.

web.php

Route::get('/document', '[email protected]')->name('document');

DocumentController.php

public function document()
{
    $keyword = request('code');
    $documents = Document::document($keyword)->latest()->get();
    return view('Home.content.documents', compact('documents'));
}

Document.php

public function scopeDocument($query, $keywords)
{
    $keywords = explode(' ',$keywords);
    foreach ($keywords as $keyword) {
        $query->where('code' , 'LIKE' , '%' . $keyword . '%');
    }
    return $query;
}

documents.blade,php

<form action="{{ route('document') }}" method="get">
    <div class="form-group">
        <label for="code">Code</label>
        <input type="text" class="form-control col-sm-4" id="code" name="code">
    </div>
    <button type="submit" class="btn btn-primary">Search</button>
</form>
<div class="text-center">
    @foreach($documents as $document)
        <h1 class="m-3">{{ $document->first_name }} {{ $document->last_name }}</h1>
        <img src="images/documents/{{ $document->image }}" class="img-fluid">
    @endforeach
</div>

Why this code is not working?

09 Aug
1 month ago

irankhosravi started a new conversation How To Get Count Order

Each user comes in for registration. And it will enter the referral code marketer. And the user enters the marketing code. And it's stored in the parent_id.

count

And marketers can see how many people bought their code.

Users table

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('first_name');
        $table->string('last_name');
        $table->string('referral_code')->nullable();
        $table->integer('parent_id')->unsigned()->nullable();
        $table->string('mobile')->unique();
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
}

Order table

public function up()
{
    Schema::create('oreders', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->bigInteger('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        $table->bigInteger('product_id')->unsigned();
        $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        $table->timestamps();
    });

}

My Controller.php

public function index()
{
$orders = Order::with('user')->where(''parent_id)->count();
    return $orders;
}

I get this error.

Call to undefined method App\Order::parent_id() (View: C:\xampp\htdocs\site\bazar\resources\views\Admin\master.blade.php)

irankhosravi left a reply on How To Find Parent_id Count?

There are not products

irankhosravi left a reply on How To Find Parent_id Count?

Each user comes in for registration. And it will enter the referral code marketer. And the user enters the marketing code. And it's stored in the parent_id.

And marketers can see how many people bought their code.

irankhosravi left a reply on How To Find Parent_id Count?

I tried replace it

$orderCount = Order::whereHas('user')->withCount('parent_id')->get();

I get this error.

Call to undefined method App\Order::parent_id() (View: C:\xampp\htdocs\site\bazar\resources\views\Admin\master.blade.php)

08 Aug
1 month ago

irankhosravi started a new conversation How To Find Parent_id Count?

How to find parent_id count?

Users table

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('first_name');
        $table->string('last_name');
        $table->string('referral_code')->nullable();
        $table->integer('parent_id')->unsigned()->nullable();
        $table->string('mobile')->unique();
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
}

Order table

public function up()
{
    Schema::create('oreders', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->bigInteger('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        $table->bigInteger('product_id')->unsigned();
        $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        $table->timestamps();
    });

}

My Controller.php

public function index()
{
$orders = Order::with('user')->where(''parent_id)->count();
    return $orders;
}

I get this error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'parent_id' in 'where clause' (SQL: select count(*) as aggregate from orders where exists (select * from users where orders.user_id = users.id) and parent_id is null)

06 Aug
1 month ago

irankhosravi left a reply on How To Find Parent_id In Users Table

Users table

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('first_name');
        $table->string('last_name');
        $table->string('referral_code')->nullable();
        $table->integer('parent_id')->unsigned()->nullable();
        $table->string('mobile')->unique();
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
}

Buy table

public function up()
{
    Schema::create('buys', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->bigInteger('user_id')->unsigned();
        $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        $table->bigInteger('product_id')->unsigned();
        $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
        $table->timestamps();
    });

}

irankhosravi left a reply on How To Find Parent_id In Users Table

no i have parent_id in users table.

irankhosravi started a new conversation How To Find Parent_id In Users Table

Look at my codes. I want to find parent_id in users table.

UserController.php

public function index ()
{
    if (auth()->user()->level == 'marketing') {
        $users = Buy::with('user')->where('parent_id', auth()->user()->id)->latest()->paginate(25);
    } else if (auth()->user()->level == 'admin') {
        $users = Buy::all();
    }
    return view('Admin.users.index', compact('users'));
}

Buy.php

public function user ()
{
    return $this->hasMany(User::class);
}

I get this error.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'parent_id' in 'where clause' (SQL: select count(*) as aggregate from buys where parent_id = 2)

05 Aug
1 month ago
04 Aug
1 month ago

irankhosravi started a new conversation How To Dispaly Alert After Save A Reports

How to display alert after save a report. and redirect to profile?

public function store (ReportRequest $request)
{
    $report = Report::where('user_id',auth()->id())
        ->where( 'order_id', request('order_id'))
        ->exists();

    if ($report) {
        alert()->error('your order already saved.','ok')->persistent('close')->html();
        return redirect()->back();
    }

    $report = new Report($request->all());
    $report->user_id = auth()->user()->id;
    $report->date = $request->date;
    $report->time = $request->time;
    $report->order_id = $request->order_id;
    $report->status = 0;
    $report->code = $request->code;
    $report->save();
    
    alert()->success('your code is '.$request->issue_number.'.'."<br>".'the reports are saving..', 'ok')->persistent('close')->html();
    return redirect()->route('user.profile');
}

I want to after save redirect to profile of user. but alert did not displayed.

It must redirect()->back();.

03 Aug
1 month ago

irankhosravi started a new conversation How To Login After Enter Verification Code In Laravel?

We have a page with a verification code that redirects to this page after the user logs in. I want to login after clicking the user confirmation button.

code

public function send(Request $request)
{
    $user = User::whereCode($request->code)->whereMobile($request->mobile)->first();
    if($user){
        $user->verification_code = 1;
        $user->save();
        
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        $this->guard()->login($user);

        return $this->registered($request, $user)
                ?: redirect($this->redirectPath());
        
    } else {
        return redirect()->back();
    }
}
02 Aug
1 month ago

irankhosravi started a new conversation Method Illuminate\Database\Eloquent\Collection::paginate Does Not Exist.

I want to merge two models in a blade. Look at my codes

public function history_posts_requests () {
    $reports = Report::latest()->where('status', '=', '1')->first()->get();
    $order_mobiles = OrderMobile::latest()->where('status', '=', '1')->first()->get();
    $allOrders = $reports->merge($order_mobiles)->paginate(50);
    return view('Admin.desktops.history_posts_requests', compact('allOrders'));
}

But I get this error.

Method Illuminate\Database\Eloquent\Collection::paginate does not exist.

29 Jul
1 month ago

irankhosravi left a reply on How To Add Link In Sweet Alert?

I want to add two links in sweet alert

irankhosravi left a reply on How To Add Link In Sweet Alert?

@cronix hi

I use laravel 5.8 version , and I installed last sweet alert

irankhosravi started a new conversation How To Add Link In Sweet Alert?

I want to add 2 links in sweet alert. but I see this picture.

sweet alert

alert()->warning("You must register now.<br>", 'OK')->html()->persistent("<a href='http://maneh.com/register' class='btn btn-primary'>register</a><a href='http://maneh.com/login' class='btn btn-primary'>login</a>");

How to add login and register buttons in sweet alert.

28 Jul
1 month ago

irankhosravi started a new conversation How To Use A Variable To All Controllers In Laravel

I defined $block to all views and controller. I want to define $block for all views. How to I do?

footer.blade.php

{!! $block[0]->body !!}
23 Jul
1 month ago

irankhosravi left a reply on Connection Could Not Be Established With Host Smtp.mailtrap.io [Connection Refused #111]

@snapey I see this message.

>>> config('mail')
=> [
     "driver" => "smtp",
     "host" => "smtp.mailtrap.io",
     "port" => "2525",
     "from" => [
       "address" => "[email protected]",
       "name" => "Example",
     ],
     "encryption" => null,
     "username" => null,
     "password" => null,
     "sendmail" => "/usr/sbin/sendmail -bs",
     "markdown" => [
       "theme" => "default",
       "paths" => [
         "C:\xampp\htdocs\urmiahardware\magzrayaneh\resources\views/vendor/mail",
       ],
     ],
     "log_channel" => null,
   ]
>>>
21 Jul
1 month ago

irankhosravi left a reply on Connection Could Not Be Established With Host Smtp.mailtrap.io [Connection Refused #111]

I registered in mailtrap.io then I go to address copied in .env

mailtrap

irankhosravi started a new conversation Connection Could Not Be Established With Host Smtp.mailtrap.io [Connection Refused #111]

What is this error?

Error

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=cf72ce10a4a459
MAIL_PASSWORD=5be60044b58cf4
MAIL_ENCRYPTION=null

irankhosravi left a reply on How To Reauired

What is $request_?

20 Jul
1 month ago

irankhosravi started a new conversation How To Reauired

How to creare if you choose marketing, you must enter the code

<div class="form-group row d-none" id="referral_code">
  <label for="referral_code">Referral Code</label>
  <div class="col-md-10">
    <input id="referral_code" type="text" class="form-control" name="referral_code">
  </div>
</div>
<input class="form-check-input" type="radio" name="familiar" id="google" value="1" onclick="showReferal(false)">
<input class="form-check-input" type="radio" name="familiar" id="friends" value="2" onclick="showReferal(false)">
<input class="form-check-input" type="radio" name="familiar" id="advertising" value="3" onclick="showReferal(false)">
<input class="form-check-input" type="radio" name="familiar" id="marketer" value="4" onclick="showReferal(true)">

MyRequest.php

<?php 

namespace App\Http\Requests;

use App\Http\Requests\Request;

class MyRequest extends Request {

    /**
     * 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 [
            if (familiar == 4) {
                'referral_code' => 'required',
            }
        ];
    }

}
19 Jul
1 month ago

irankhosravi started a new conversation How To Show Parent_id == Id

I have a users table with below fields.

users table

I want to show parent_id for id. when if john trump is logined.

17 Jul
2 months ago

irankhosravi left a reply on Javascript D-block Not Working.

@tray2

Can you send complete codes. because I added below codes in my project.

    function showReferal() {
        document.querySelector('#referral_code').classList.remove('d-none');
        document.querySelector('#referral_code').classList.add('d-block');
    }

It did not work.

irankhosravi left a reply on Javascript D-block Not Working.

OK , So, When I click on advertising and google and friends , referral_code must be hidden. only marketer be show

irankhosravi left a reply on Javascript D-block Not Working.

I edited my post

irankhosravi left a reply on Javascript D-block Not Working.

Which new question?

irankhosravi started a new conversation Javascript D-block Not Working.

We have many radio input.

<div class="form-group row d-none" id="referral_code">
    <label for="referral_code">Referral Code</label>
<div class="col-md-10">
    <input id="referral_code" type="text" class="form-control" name="referral_code">
</div>
</div>
<input class="form-check-input" type="radio" name="familiar" id="google" value="1">
<input class="form-check-input" type="radio" name="familiar" id="friends" value="2">
<input class="form-check-input" type="radio" name="familiar" id="advertising" value="3">
<input class="form-check-input" type="radio" name="familiar" id="marketer" value="4">>

And when I click on #marketer should show #referral_code.

$("#marketer").click(function() {
    $('#referral_code').toggleClass('d-block');
});
16 Jul
2 months ago

irankhosravi started a new conversation How To Display An Element With Javascript

I want to display #referral_code

    $("#marketer").click(function() {
        $('#referral_code').css('d-block');
    });

The #referral_code is hidden , I want click #referral_code, that be show or block.

08 Jul
2 months ago

irankhosravi left a reply on How To Toggle Div By Clicking Radio Button?

What do you mean?

What's the solution?

irankhosravi left a reply on How To Toggle Div By Clicking Radio Button?

I get this error

TypeError: marketer is not a function

irankhosravi started a new conversation How To Toggle Div By Clicking Radio Button?

By default the both reagent_code should be hidden. By selecting the radio button, have to show the appropriate DIV (following its #id).

html

<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="marketer" id="yes" onclick="marketer(1)" value="1">
  <label class="form-check-label" for="yes">Yes</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="marketer" id="no" onclick="marketer(0)" value="0">
  <label class="form-check-label" for="no">No</label>
</div>

footer

<script src="{{ asset('themes/js/jquery-3.3.1.slim.min.js') }}"></script>
<script src="{{ asset('themes/js/jquery.min.js') }}"></script>
<script src="{{ asset('themes/js/popper.min.js') }}"></script>
<script src="{{ asset('themes/js/bootstrap.min.js') }}"></script>
<script src="{{ asset('themes/js/jquery.md.bootstrap.datetimepicker.js') }}"></script>
<script>
    $('#date').MdPersianDateTimePicker({
        targetTextSelector: '#birth_date',
    });
</script>
<script>
    $(document).on('change', '#province_id', function() {
        let province_id = $(this).val();
        let select = $('#city_id');

        $.ajax({
            type: 'get',
            url: '{{ route('findIDProvince') }}',
            data: {'id':province_id},
            success: function(data){
                select.html('');
                for (var i = 0; i < data.length; i++){
                    select.append('<option value="'+data[i].id+'">'+data[i].city_name+'</option>');
                }
            },
            error: function(){
                console.log('this is a error');
            },
        });
    }).trigger('change');

function marketer(x) {
  if (x == 0) {
    document.getElementById('reagent_code').adddClass='d-none';
  } else if (x == 1) {
    document.getElementById('reagent_code').adddClass='d-block';
    return;
  }
}
07 Jul
2 months ago

irankhosravi left a reply on Reagent Code

How does the laravel tracking code work in the user table? If you can put it along with the source and description here.

An application should have, for example, you introduce a friend. Then when you want to register, you register with the code of your agent. Most of this friend's name is registered with your code. Below you can subscribe to this subset. It's a good idea for you to do this in a whisper that you did not say. It might not be in the way of this Hat subset, and maybe the total number of people who became your body code with your body

irankhosravi started a new conversation Reagent Code

How to create reagent code in users table?

irankhosravi left a reply on How To Show Multiple Table In A Blade?

@snapey

I want to this code for display for example.

<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>

irankhosravi left a reply on How To Show Multiple Table In A Blade?

Yes, my problem here is this. I don't want to this code.

<td>1 4</td>
<td>1 5</td>
<td>1 6</td>
<td>2 4</td>
<td>2 5</td>
<td>2 6</td>
<td>3 4</td>
<td>3 5</td>
<td>3 6</td>

I want to this code for display for example.

<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
06 Jul
2 months ago