irankhosravi

irankhosravi

Member Since 1 Year Ago

Experience Points 11,060
Experience Level 3

3,940 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 Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

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

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

21 May
10 hours ago

irankhosravi left a reply on Array To String Conversion

@CRONIX - This information is for send of sms.

20 May
1 day ago

irankhosravi left a reply on Array To String Conversion

I asked why I see this error?

irankhosravi left a reply on Array To String Conversion

I asked why I see this error?

irankhosravi left a reply on Array To String Conversion

I asked why I see this error?

irankhosravi started a new conversation Array To String Conversion

Look at my codes

web.php

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

HomeController.php

<?php

namespace App\Http\Controllers;

use App\Blog;
use App\Faq;
use App\SendSMS;
use App\Service;
use App\Slideshow;
use App\User;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Show the application dashboard.
     *
     * @return void
     */
    public function index()
    {
        $slideshows = Slideshow::latest()->get();
        $services = Service::latest()->get();
        $faqs = Faq::latest()->get();
        $blogs = Blog::latest()->get();
        return view('Home.index', compact('slideshows', 'services', 'faqs', 'blogs'));
    }

    public function machines()
    {
        return view('Home.machines');
    }

    public function networks()
    {
        return view('Home.networks');
    }

    public function computers()
    {
        return view('Home.computers');
    }

    public function internets()
    {
        return view('Home.internets');
    }

    public function code()
    {
        return view('Home.send');
    }

    public function send(Request $request, $mobile = '09389267856')
    {
        if($request->ajax()) {
            $request->validate([
                'mobile_number' => 'required',
            ]);
            $sendSms = new SendSMS;
            $sendSms->mobile_number = $request->mobile_number;
            $sendSms->code = rand(10000,99999);
            if ($sendSms->save()) {
                try {
                    $api = new \Kavenegar\KavenegarApi("Example Api");
                    $sender = "10004346";
                    $message = " $sendSms->code ";
                    $receptor = $mobile;
                    $result = $api->Send($sender, $receptor, $message);
                    if ($result) {
                        foreach ($result as $r) {
                            echo "messageid = $r->messageid";
                            echo "message = $r->message";
                            echo "status = $r->status";
                            echo "statustext = $r->statustext";
                            echo "sender = $r->sender";
                            echo "receptor = $r->receptor";
                            echo "date = $r->date";
                            echo "cost = $r->cost";
                        }
                    }
                } catch (\Kavenegar\Exceptions\ApiException $e) {
                    echo $e->errorMessage();
                } catch (\Kavenegar\Exceptions\HttpException $e) {
                    echo $e->errorMessage();
                }
            }
            return response()->json(['data' => $request->mobile_number, 'id' => $sendSms->id]);
        }
    }
}

send.blade.php

@extends('Home.master')

@section('content')

    <div id="networks" class="pt-5 pb-5 mt-5">
        <div class="container">
            <div class="row">
                <div class="col-md-4 m-auto">
                    <div class="card mt-3">
                        <div class="card-header">
                            <h4>Regisiter</h4>
                        </div>
                        <div class="card-body">
                            <form id="FormSend">
                                <div class="form-group" id="form-group-1">
                                    <label for="mobile_number">Mobie</label>
                                    <input type="text" class="form-control" name="mobile_number" id="mobile_number">
                                </div>
                                <div class="form-group" id="form-group-2">
                                    <label for="code">Code</label>
                                    <input type="text" class="form-control" name="code" id="code">
                                </div>
                                <div class="form-group">
                                    <button type="submit" class="btn btn-danger" id="btn-ok">تاییذ</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script>

        $(document).ready(function(){
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $("#btn-ok").click(function () {
                $("#form-group-1").hide();
                $("#form-group-2").fadeIn();
            });


            $('form').submit(function (event) {
                event.preventDefault();
                mobile_number = $('#mobile_number').val();
                $.post("{{ route('send') }}", {mobile_number:mobile_number}, function (data) {
                    $('#mobile_number').val('');
                    console.log(data);
                });
            });
        });
    </script>
@endsection

When I after save mobile number I see this error.

Error Ajax

irankhosravi started a new conversation The GET Method Is Not Supported For This Route. Supported Methods: POST.

Look at my codes

web.php

Route::post('/code', '[email protected]')->name('code');
Route::post('/send', '[email protected]')->name('send');

HomeController.php

public function code()
{
    return view('Home.send');
}

public function send ($mobile = '09389267856')
{
    try{
        $api = new \Kavenegar\KavenegarApi( 

"416576364B7A5552744A4852415477536254534C367755496E4F32344F426768" ); }

send,blade.php

 <form action="{{ route('send') }}" method="post">
        ........./*code gereI*/
 </form

I see this error.

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException The GET method is not supported for this route. Supported methods: POST.

18 May
3 days ago

irankhosravi left a reply on How To Update And Edit A Image In Laravel 5.8

I replaced images to image now. but my problem did not solve.

irankhosravi left a reply on How To Update And Edit A Image In Laravel 5.8

I just upload the image with the .jpg extension.

irankhosravi left a reply on How To Update And Edit A Image In Laravel 5.8

How do you do it to update the image?

irankhosravi left a reply on How To Update And Edit A Image In Laravel 5.8

namespace App\Http\Controllers\Admin;

use App\Http\Requests\ServiceRequest;
use App\Service;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

irankhosravi left a reply on How To Update And Edit A Image In Laravel 5.8

@SNAPEY - No. In the edit page, after I see null, after upload my image.

irankhosravi left a reply on How To Update And Edit A Image In Laravel 5.8

@SNAPEY - Does the file get updated in the file system? No.

Everything is okay $fillable,......

I writed in Controller

public function update(Request $request, Service $service)
{
    dd($service);
}

I see this message

Service {#336 ▼
  #fillable: array:4 [▶]
  #connection: "mysql"
  #table: "services"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:8 [▼
    "id" => 5
    "user_id" => 1
    "title" => "laptop"
    "image" => "ghali.png"
    "body" => "<p>A laptop computer (also shortened to just laptop; or called a notebook or notebook computer) is a small, portable personal computer (PC) with a &quot;clamshe ▶"
    "slug" => "پرده-شویی"
    "created_at" => "2019-05-18 07:32:02"
    "updated_at" => "2019-05-18 20:14:27"
  ]
  #original: array:8 [▶]
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

Service {#336 ▼
  #fillable: array:4 [▶]
  #connection: "mysql"
  #table: "services"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:8 [▼
    "id" => 5
    "user_id" => 1
    "title" => "laptop"
    "image" => "ghali.png"
    "body" => "<p>A laptop computer (also shortened to just laptop; or called a notebook or notebook computer) is a small, portable personal computer (PC) with a &quot;clamshe ▶"
    "slug" => "پرده-شویی"
    "created_at" => "2019-05-18 07:32:02"
    "updated_at" => "2019-05-18 20:14:27"
  ]
  #original: array:8 [▶]
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}
Service {#336 ▼
  #fillable: array:4 [▶]
  #connection: "mysql"
  #table: "services"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:8 [▼
    "id" => 5
    "user_id" => 1
    "title" => "laptop"
    "image" => "ghali.png"
    "body" => "<p>A laptop computer (also shortened to just laptop; or called a notebook or notebook computer) is a small, portable personal computer (PC) with a &quot;clamshe ▶"
    "slug" => "پرده-شویی"
    "created_at" => "2019-05-18 07:32:02"
    "updated_at" => "2019-05-18 20:14:27"
  ]
  #original: array:8 [▶]
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

This is the previous photo. My new photo is 1.jpg.

irankhosravi started a new conversation How To Update And Edit A Image In Laravel 5.8

I have a table called Services, now this table has the following -

-id -title -body -image -slug -timestamps

And in administrator, services page I created for Add, Edit, Delete it.

My problem is edit and update a image. A strange problem is that, when I change the of image to aaaaa field in the service table (database), Nothing happens. should happen. because I changed rename of image to aaaaa.

web.php

Route::resource('services', 'ServiceController');

ServiceController.php

public function edit(Service $service)
{
    return view('Admin.services.edit', compact('service'));
}

public function update(Request $request, Service $service)
{
    $service->title = $request->title;
    $service->body = $request->body;

    if($request->hasFile('image')) {
        $image = $request->file('image');
        $filename = $image->getClientOriginalName();
        $image->move(public_path('images/services'), $filename);
        $service->image = $request->file('image')->getClientOriginalName();
    }

    $service->update();

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

edit.blade.php

<form class="form-horizontal" action="{{ route('services.update', $service->id) }}" method="post" enctype="multipart/form-data">
    {{ csrf_field() }}
    {{ method_field('PATCH') }}
    @include('Admin.layouts.errors')
    <div class="form-group">
        <label for="title">Title</label>
        <input type="text" class="form-control" id="title" name="title" placeholder="Title" value="{{ $service->title ? : old('title') }}">
    </div>
    <div class="form-group">
        <label for="body">Body</label>
        <textarea class="form-control" rows="10" id="body" name="body" placeholder="Body">{{ $service->body ? : old('body') }}</textarea>
    </div>
    <div class="form-group">
        <label for="image">Image</label>
        <div class="custom-file">
            <input type="file" class="custom-file-input" id="image" name="image">
            <label class="custom-file-label" for="image">Image</label>
        </div>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-primary">Save</button>
    </div>
</form>

Service.php

protected $fillable = [
    'title',
    'body',
    'image',
    'slug',
];

I even changed the controller in the update method as follows, nothing happened.

$service->save();

irankhosravi left a reply on How To Set .active With Laravel In Css?

@BAGIO007 - I did not understand what you said?

17 May
4 days ago

irankhosravi started a new conversation How To Set .active With Laravel In Css?

I tried to show slideshow for first image be show.

<div id="home" class="pt-5">
    <div class="bd-example">
        <div id="carouselSlider" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                @foreach($slideshows as $slideshow)
                    <li data-target="#carouselSlider" data-slide-to="{{ $slideshow->id }}" class="active"></li>
                @endforeach
            </ol>
            <div class="carousel-inner">
                @foreach($slideshows as $slideshow)
                    <div class="carousel-item active">
                        <img src="images/slideshows/{{ $slideshow->image }}" class="d-block w-100">
                        <div class="carousel-caption d-none d-md-block">
                            <h5>{{ $slideshow->title }}</h5>
                            <p>{!! str_limit($slideshow->body, 50) !!}</p>
                        </div>
                    </div>
                @endforeach
            </div>
            <a class="carousel-control-prev" href="#carouselSlider" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
            </a>
            <a class="carousel-control-next" href="#carouselSlider" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>
    </div>
</div>

irankhosravi started a new conversation How To Create Two Columns With @foreach?

HomeController.php

public function index()
{
    $slideshows = Slideshow::latest()->get();
    $services = Service::latest()->get();
    $faqs = Faq::latest()->get();
    return view('Home.index', compact('slideshows', 'services', 'faqs'));
}

home.blade.php

        <div class="row">
            @foreach($services as $row)
                <div class="col-md-6" data-aos="fade-right" data-aos-duration="2000">
                    @foreach($row as $service)
                        <div class="media mb-5">
                            <img src="images/services/{{ $service->image }}" class="rounded-circle" />
                            <div class="media-body">
                                <h5 class="mt-0">{{ $service->title }}</h5>
                                <p>{!! str_limit($service->body, 50) !!}</p>
                                <a href="{{ $service->path() }}">More Details</a>
                            </div>
                        </div>
                    @endforeach
                </div>
            @endforeach
        </div>

Error is:

Trying to get property of non-object (View: C:\xampp....)

Can you fix it? I don't have any idea what happened.

irankhosravi left a reply on Logout In Laravel Not Working

@CRONIX - Thank you size of a world

irankhosravi left a reply on Logout In Laravel Not Working

No , I am using jQuery And I use jquery and bootstrap to the latest version. I do not use VUE.JS

Thanks for answer.

irankhosravi left a reply on Logout In Laravel Not Working

@MAVERICKCHAN - I get this error! AGAIN

SyntaxError: 'http://localhost:8000/logout' is not a valid selector bootstrap.min.js:6
getSelectorFromElement http://localhost:8000/themes/js/bootstrap.min.js:6
refresh http://localhost:8000/themes/js/bootstrap.min.js:6
map self-hosted:286
refresh http://localhost:8000/themes/js/bootstrap.min.js:6
n http://localhost:8000/themes/js/bootstrap.min.js:6
_jQueryInterface http://localhost:8000/themes/js/bootstrap.min.js:6
jQuery 2
_jQueryInterface http://localhost:8000/themes/js/bootstrap.min.js:6
<anonymous> http://localhost:8000/themes/js/script.js:24
<anonymous> http://localhost:8000/themes/js/script.js:1

irankhosravi left a reply on Logout In Laravel Not Working

@KANE - What does it mean?

irankhosravi left a reply on Logout In Laravel Not Working

@KANE - What does it mean?

irankhosravi left a reply on Logout In Laravel Not Working

@MUNAZZIL - I did not see anything.

Where to add?

irankhosravi left a reply on Logout In Laravel Not Working

@MTHOMAS - I did not change it. Please help me. I'm in a hurry.

Thanks for answer.

irankhosravi left a reply on Logout In Laravel Not Working

@MAVERICKCHAN - I deleted it but I did not solve yet.

irankhosravi left a reply on Logout In Laravel Not Working

@MAVERICKCHAN - I deleted it but I did not solve yet.

irankhosravi started a new conversation Logout In Laravel Not Working

Look at my codes

@else
    <li class="nav-item dropdown">
        <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
            {{ Auth::user()->first_name }}&nbsp;{{ Auth::user()->last_name }} <span class="caret"></span>
        </a>

        <div class="dropdown-menu dropdown-menu-left" aria-labelledby="navbarDropdown">
            <a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                {{ __('Logout') }}
            </a>

            <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                @csrf
            </form>
        </div>
    </li>
@endguest

I see this error. I tried solve this problem but I did not successful.

Console

16 May
5 days ago

irankhosravi left a reply on How To Update A Product In Laravel 5,8

OK, I go to database now, I changed in image to picture, then I go my project, and I tested this again.

But it did not event for me.

I changed

public function update(ProductRequest $request, Product $product)

To

public function update(Request $request, Product $product)

irankhosravi left a reply on How To Update A Product In Laravel 5,8

I changed it but I see in database, the image did not change.

irankhosravi left a reply on How To Update A Product In Laravel 5,8

@YEZAWHEIN - Thanks for answer.

I want to update image in database.

irankhosravi left a reply on How To Update A Product In Laravel 5,8

@YEZAWHEIN - Thanks for answer.

I want to update image in database.

irankhosravi left a reply on How To Update A Product In Laravel 5,8

@CRONIX - Hi.

What's the solution?

15 May
6 days ago

irankhosravi started a new conversation How To Update A Product In Laravel 5,8

I have a product I want to edit a product

Look at my codes

public function update(ProductRequest $request)
{
    $product->user_id = auth()->user()->id;
    $product->title = $request->title;
    $product->body = $request->body;
    $product->price = $request->price;

    if($request->has('image')) {
        $image = $request->file('image');
        $filename = $image->getClientOriginalName();
        $image->move(public_path('images/products'), $filename);
        $product->image = $request->file('image')->getClientOriginalName();
    }

    $product->update();

    $product->categories()->sync($request->category);

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

Everything changes except image.

irankhosravi left a reply on AOS With Jquery.easing.min.js Not Working

Is there anyone answering my question?

irankhosravi left a reply on AOS With Jquery.easing.min.js Not Working

@MVD - OK,

What's the solution?

I mean, what code should I write?

irankhosravi left a reply on AOS With Jquery.easing.min.js Not Working

Let me explain this.

When I just put this code:

AOS.init({
        easing: 'ease-in-out-sine'
});

And delete the rest in the script file.

The problem is resolved and the AOS works.