oxbir

oxbir

Member Since 5 Months Ago

Experience Points
1,930
Total
Experience

3,070 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
0
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.

Level 1
1,930 XP
May
16
2 weeks ago
Activity icon

Started a new Conversation Uncaught PDOException: SQLSTATE[42000]: Syntax Error Or Access Violation: 1064 You Have An Error In Your SQL Syntax;

I've looked through all the other StackOverflow (and google) posts with the same problem, but none seemed to address my problem.

I am using PDO and PHP.

Login.php

function check($data)
{
    $email = $data['email'];
    $password = $data['password'];
    $sql = "SELECT * FROM users WHERE email = ? password = ?";
    $params = [$email, $password];
    $result = $this->doSelect($sql, $params);
    print_r($result);
    //if (sizeof($result) > 0) {
    //     echo 'yes';
    //} else {
    //    echo 'no';
    //}
}

Model.php

function doSelect($sql, $values = [], $fetch = '', $fetchStyle = PDO::FETCH_OBJ) {
    $stmt = self::$connection->prepare($sql);
    foreach ($values as $key => $value) {
        $stmt->bindValue($key + 1, $value);
    }
    $stmt->execute();
    if ($fetch == '') {
        $result = $stmt->fetchAll($fetchStyle);
    } else {
        $result = $stmt->fetch($fetchStyle);
    }
    return $result;
}

I get this error.

Errorimage description here

Apr
27
1 month ago
Activity icon

Replied to How To Update & Edit In Php Mvc?

database

I have a table of categories

Apr
26
1 month ago
Activity icon

Replied to How To Update & Edit In Php Mvc?

@tray2 yes there isi exists in the database.

Activity icon

Replied to How To Update & Edit In Php Mvc?

My problem is did not saving and I did not any an error.

Activity icon

Started a new Conversation How To Update & Edit In Php Mvc?

I want to edit in php mvc.

edit.php

<form action="CategoryController/edit/<?= $CategoryData->id ?>" method="post">
    <div class="form-group">
        <label for="name">name</label>
        <input type="text" id="name" name="name" value="<?= $CategoryData->name ?>" class="form-control">
    </div>
    <div class="form-group">
        <label for="parent_id">parent id</label>
        <select id="parent_id" name="parent_id" class="form-control">
            <?php $categories = $data[0] ?>
            <?php foreach ($categories as $category) { ?>
                <?php
                if ($category->id == $CategoryData->parent_id) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                ?>
                <option value="<?= $category->id ?>" <?= $selected ?>><?= $category->name ?></option>
            <?php } ?>
        </select>
    </div>
    <div class="form-group">
        <button name="update" type="submit" class="btn-save">save</button>
    </div>
</form>

CategoryController.php

function edit($category_id = 0, $edit = null)
{
    if (isset($_POST['update'])) {
        $name = $_POST['name'];
        $parent_id = $_POST['parent_id'];
        $this->model->update($name, $parent_id, $edit, $category_id);
    }

    $categories = $this->model->getCategories();
    $CategoryData = $this->model->CategoryData($category_id);
    $data = [$categories, $category_id,  $CategoryData];
    $this->view('admin/categories/edit', $data);
}

model Category.php

function update ($name, $parent_id, $id)
{
    $sql = "UPDATE categories SET name = ?, parent_id = ? WHERE id = ?";
    $stmt = self::$connection->prepare($sql);
    $stmt->bindValue(1, $name);
    $stmt->bindValue(2, $parent_id);
    $stmt->bindValue(3, $id);
    $stmt->execute();
}
Apr
05
1 month ago
Activity icon

Replied to How To Import Multi Carousel Item Slider In Project?

Are They Working With LARAVEL WITH BOOTTTRAOP?

Activity icon

Started a new Conversation How To Import Multi Carousel Item Slider In Project?

I have tried to change my code from this solution Dynamic carousel in PHP Laravel only shows four image but didn't work

       <div class="row">
        <div class="bd-example">
            <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">

                <ol class="carousel-indicators">
                    @foreach($galleries as $value)
                        <li data-target="#carouselExampleCaptions" data-slide-to="{{ $loop->index }}" class="{{ $loop->first ? 'active' : '' }}"></li>
                    @endforeach
                </ol>
                <div class="carousel-inner">
                    @foreach($galleries->chunk(4) as $galleryCollection)
                        <div class="carousel-item {{ $loop->first ? 'active' : '' }}">
                            @foreach ($galleryCollection as $gallery)
                                <div class="col-md-3">
                                    <img src="{{ asset('images/galleries/'.$gallery->image) }}" class="d-block w-100">
                                </div>
                            @endforeach
                        </div>
                    @endforeach
                </div>
                <a class="carousel-control-prev" href="#carouselExampleCaptions" 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="#carouselExampleCaptions" 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>

Something like that . https://jsfiddle.net/irankhosravi/k7wpszuy/ But I want to get data from database using foreach. I searched in google.com But it did not find.

Apr
03
1 month ago
Activity icon

Replied to How To Import Multi Carousel Item Slider In Project?

Something like that . https://jsfiddle.net/irankhosravi/k7wpszuy/ But I want to get data from database using foreach. I searched in google.com But it did not find.

Apr
02
1 month ago
Activity icon

Replied to How To Import Multi Carousel Item Slider In Project?

Something like that . https://jsfiddle.net/irankhosravi/k7wpszuy/ But I want to get data from database using foreach. I searched in google.com But it did not find.

Activity icon

Replied to How To Import Multi Carousel Item Slider In Project?

I asked, Why this my codes do not work?

Activity icon

Started a new Conversation How To Import Multi Carousel Item Slider In Project?

I have tried to change my code from this solution Dynamic carousel in PHP Laravel only shows four image but didn't work

       <div class="row">
        <div class="bd-example">
            <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">

                <ol class="carousel-indicators">
                    @foreach($galleries as $value)
                        <li data-target="#carouselExampleCaptions" data-slide-to="{{ $loop->index }}" class="{{ $loop->first ? 'active' : '' }}"></li>
                    @endforeach
                </ol>
                <div class="carousel-inner">
                    @foreach($galleries->chunk(4) as $galleryCollection)
                        <div class="carousel-item {{ $loop->first ? 'active' : '' }}">
                            @foreach ($galleryCollection as $gallery)
                                <div class="col-md-3">
                                    <img src="{{ asset('images/galleries/'.$gallery->image) }}" class="d-block w-100">
                                </div>
                            @endforeach
                        </div>
                    @endforeach
                </div>
                <a class="carousel-control-prev" href="#carouselExampleCaptions" 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="#carouselExampleCaptions" 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>
Activity icon

Replied to How To Import Multi Carousel Item Slider In Project?

Yes, but if one by one it moves, that would be great.

Apr
01
1 month ago
Activity icon

Started a new Conversation How To Import Multi Carousel Item Slider In Project?

I can't figure out how to make it show 4 images instead of 3.

     <div class="row">
            <div class="bd-example">
                <div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">

                    <ol class="carousel-indicators">
                        @foreach($galleries as $value)
                            <li data-target="#carouselExampleCaptions" data-slide-to="{{ $loop->index }}" class="{{ $loop->first ? 'active' : '' }}"></li>
                        @endforeach
                    </ol>
                    <div class="carousel-inner">
                        @foreach($galleries->chunk(4) as $galleryCollection)
                            <div class="carousel-item {{ $loop->first ? 'active' : '' }}">
                                @foreach ($galleryCollection as $gallery)
                                    <div class="col-md-3">
                                        <img src="{{ asset('public/images/galleries/'.$gallery->image) }}" class="d-block w-100">
                                    </div>
                                @endforeach
                            </div>
                        @endforeach
                    </div>
                    <a class="carousel-control-prev" href="#carouselExampleCaptions" 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="#carouselExampleCaptions" 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>
Mar
31
2 months ago
Activity icon

Started a new Conversation How To Filter Data In Laravel Mysql?

I am trying to code a search box that will search though a column in my database. If the search matches the column then that record will be printed in the table below.

I am searching on a column that contains the county of a company record. There are no errors being displayed however when I search for a category and date and age, that is in the database the table remains blank. I can't see what I have done wrong in theory I think the code should work! Any help would be appreciated.

result.blade.php

<div class="container mt-5 mb-5">
    <h2>{{ __('message.menu.tournament_results') }}</h2>
    <form action="{{ route('filter') }}" method="post" class="mt-5 mb-5">
        @csrf
        <div class="row">
            <div class="form-group col-md-3">
                <label for="category">category</label>
                <select id="category" name="category" class="form-control">
                    @foreach(\App\Category::whereParent_id(62)->get() as $category)
                        <option value="{{ $category->id }}">{{ $category->name}}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group col-md-3">
                <label for="age">age</label>
                <select id="age" name="age" class="form-control">
                    @foreach(\App\Age::all() as $age)
                        <option value="{{ $age->id }}">{{ $age->title_fa}}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group col-md-3">
                <label for="date">date</label>
                <input type="text" id="date" name="date" class="form-control" />
                <span id="spanDate"></span>
            </div>
            <div class="form-group col-md-3 mt-4">
                <button class="btn btn-success btn-block">submit</button>
            </div>
        </div>
    </form>
    @if ($results)
        <div class="table-responsivemt-5 mb-5">
            <table class="table">
                <thead>
                <tr>
                    <th>{{ __('message.ages.id') }}</th>
                    <th>{{ __('message.ages.first_last_name') }}</th>
                    <th>{{ __('message.ages.province') }}</th>
                    <th>{{ __('message.ages.style') }}</th>
                    <th>{{ __('message.ages.age') }}</th>
                    <th>{{ __('message.ages.weight') }}</th>
                    <th>{{ __('message.ages.position') }}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($results as $result)
                    <tr>
                        <td>{{ $result->id }}</td>
                        <td>{{ $result->first_last_name }}</td>
                        <td>{{ $result->province->province_name }}</td>
                        <td>{{ $result->style }}</td>
                        <td>{{ $result->age }}</td>
                        <td>{{ $result->weight }}</td>
                        <td>{{ $result->role }}</td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    @endif
</div>

web.php

Route::get('/result', '[email protected]')->name('result.index');
Route::post('/result/store', '[email protected]')->name('filter');

ResultController.php

public function filter()
{
    $results = Result::filter()->paginate(12);
    return view('Home.result', compact('results'));
}

Result.php

public function scopeFilter($query)
{
    $category = request('category');
    if( isset($category) && trim($category) != '' && $category != 'all') {
        $query->whereHas('categories' , function ($query) use ($category) {
            $query->whereId($category);
        });
    }

    $age = request('age');
    if(isset($age) && trim($age) != '') {
        if($age) {
            $query->whereAge($age);
        }
    }

    $date = request('date');
    if(request('date')) {
        $query->oldest();
    } else {
        $query->latest();
    }

    return $query;
}
Mar
30
2 months ago
Activity icon

Started a new Conversation The GET Method Is Not Supported For This Route. Supported Methods: POST.

Look at my codes

result.blade.php

<div class="container mt-5 mb-5">
    <h2>{{ __('message.menu.tournament_results') }}</h2>
    <form action="{{ route('filter') }}" method="post" class="mt-5 mb-5">
        @csrf
        <div class="row">
            <div class="form-group col-md-3">
                <label for="category">category</label>
                <select id="category" name="category" class="form-control">
                    @foreach(\App\Category::whereParent_id(62)->get() as $category)
                        <option value="{{ $category->id }}">{{ $category->name}}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group col-md-3">
                <label for="age">age</label>
                <select id="age" name="age" class="form-control">
                    @foreach(\App\Age::all() as $age)
                        <option value="{{ $age->id }}">{{ $age->title_fa}}</option>
                    @endforeach
                </select>
            </div>
            <div class="form-group col-md-3">
                <label for="date">date</label>
                <input type="text" id="date" name="date" class="form-control" />
                <span id="spanDate"></span>
            </div>
            <div class="form-group col-md-3 mt-4">
                <button class="btn btn-success btn-block">submit</button>
            </div>
        </div>
    </form>
    @if ($results)
        <div class="table-responsivemt-5 mb-5">
            <table class="table">
                <thead>
                <tr>
                    <th>{{ __('message.ages.id') }}</th>
                    <th>{{ __('message.ages.first_last_name') }}</th>
                    <th>{{ __('message.ages.province') }}</th>
                    <th>{{ __('message.ages.style') }}</th>
                    <th>{{ __('message.ages.age') }}</th>
                    <th>{{ __('message.ages.weight') }}</th>
                    <th>{{ __('message.ages.position') }}</th>
                </tr>
                </thead>
                <tbody>
                @foreach($results as $result)
                    <tr>
                        <td>{{ $result->id }}</td>
                        <td>{{ $result->first_last_name }}</td>
                        <td>{{ $result->province->province_name }}</td>
                        <td>{{ $result->style }}</td>
                        <td>{{ $result->age }}</td>
                        <td>{{ $result->weight }}</td>
                        <td>{{ $result->role }}</td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    @endif
</div>

web.php

Route::get('/result', '[email protected]')->name('result.index');
Route::post('/result/store', '[email protected]')->name('filter');

ResultController.php

public function filter()
{
    $results = Result::filter()->paginate(12);
    return view('Home.result', compact('results'));
}

Result.php

public function scopeFilter($query)
{
    $category = request('category');
    if( isset($category) && trim($category) != '' && $category != 'all') {
        $query->whereHas('categories' , function ($query) use ($category) {
            $query->whereId($category);
        });
    }

    $age = request('age');
    if(isset($age) && trim($age) != '') {
        if($age) {
            $query->whereAge($age);
        }
    }

    $date = request('date');
    if(request('date')) {
        $query->oldest();
    } else {
        $query->latest();
    }

    return $query;
}

I want to filter category, age, date. But It did not worked.

Mar
24
2 months ago
Activity icon

Started a new Conversation Invalid Argument Supplied For Foreach()

Look at my codes, Please.

CategoryController.php

public function gallery($id)
{
    $category = Category::where('id', $id)->first();
    $galleries = $category->galleries()->paginate(25);
    return view('Home.categories.gallery', compact('category', 'galleries'));
}

Category.php

public function galleries()
{
    return $this->belongsToMany(Gallery::class,'category_gallery','category_id','gallery_id');
}

gallery.blade.php

@extends('Home.master')

@section('contents')
    <div class="bg-white">
        <div class="container">
            <h2 class="mb-5 mt-5">{{ $category->name }}</h2>
            <div class="row">
                @foreach($galleries as $gallery)
                    @foreach($gallery->galleries as $c)
                        {{ dd($c) }}
                        <div class="col-md-3 col-sm-6 col-12">
                            <div class="image_tn rounded border mb-2">
                                <a href="{{ asset('public/images/galleries/'.$c->image) }}" data-showsocial="true" data-thumbnail="{{ asset('public/images/galleries/'.$c->image) }}" class="html5lightbox" data-group="set1" data-width="800" data-height="600" title="{{ $c->title }}">
                                    <img src="{{ asset('public/images/galleries/'.$c->image) }}" class="img-fluid d-block mx-auto rounded" alt="{{ $c->title }}"/>
                                </a>
                            </div>
                        </div>
                    @endforeach
                @endforeach
            </div>
        </div>
    </div>
@endsection

I get this error.

Invalid argument supplied for foreach()

Mar
18
2 months ago
Activity icon

Replied to How To Get Video Of Categories?

This is supposed to be the following line

Category.php

public function videos()
{
    return $this->belongsToMany(Video::class);
}
Activity icon

Started a new Conversation How To Get Video Of Categories?

I have a category_video with only 39 and 40.

table

Look at my codes.

web.php

Route::get('/videos/category/{category_id}', '[email protected]')->name('category.video');

CategoryController.php

public function video($id)
{
    $category = Category::where('id', $id)->first();
    $videos = $category->videos()->paginate(25);
    return view('Home.categories.videos', compact('category', 'videos'));
}

videos.blade.php

<div class="bg-white">
    <div class="container">
        <h2 class="mb-5 mt-5">{{ $category->name }}</h2>
        <div class="row">
            @foreach($videos as $video)
                @foreach($video->videos as $c)
                    <div class="col-md-3 col-sm-6 col-12">
                        <div class="image_tn rounded border mb-2">
                            <a href="{{ asset('public/videos/'.$c->video) }}" data-showsocial="true" data-thumbnail="{{ asset('public/videos/'.$c->image) }}" class="html5lightbox" data-group="set1" data-width="800" data-height="600" title="{{ $c->title }}">
                                <img src="{{ asset('public/videos/'.$c->image) }}" class="img-fluid d-block mx-auto rounded" alt="{{ $c->title }}"/>
                            </a>
                        </div>
                    </div>
                @endforeach
            @endforeach
        </div>
    </div>
</div>

Category.php

public function videos()
{
    return $this->belongsToMany(Video::class);
}

When I click on a category for example id of 39.

Show videos that have their ID equal to 39. But I see both 39 and 40.

Mar
17
2 months ago
Activity icon

Started a new Conversation Invalid Argument Supplied For Foreach()

Look at my codes

web.php

Route::get('/news/category/{category}' , '[email protected]')->name('category.news');

CategoryController.php

public function news($id)
{
    $cat = Category::where('id',$id)->first();
    $categories = $cat->news()->paginate(25);

    return view('Home.categories.news', compact('categories'));
}

Category.php

public function news()
{
    return $this->belongsToMany(News::class);
}

news.blade.php

<div class="bg-white">
    @foreach($categories as $item)
        @foreach($item->news as $news)
            <h2>{{ $news->title }}</h2>
        @endforeach
        <div class="container mt-5 mb-5">
            <div class="row">
                <div class="col-md-2">
                    <p><img src="{{ asset('public/images/news/'.$item->image) }}" class="img-fluid"></p>
                    <h5 class="text-center"><a href="{{ $item->path() }}">{{ $item->title }}</a></h5>
                </div>
            </div>
        </div>
    @endforeach
</div>

I want to return title of news. I see this error.

Invalid argument supplied for foreach()

Mar
15
2 months ago
Activity icon

Replied to How To Show Categories Video?

Answer my question///

Activity icon

Started a new Conversation How To Show Categories Video?

Look at my codes.

I have a sub menu of categories and I want show in videos category,

The sub menus are title of categories.

header.blade.php

<ul class="dropdown-menu">
	@foreach($videos as $video)
		@if(app()->getLocale() == 'ar')
			<li><a class="dropdown-item text-right"
				   href="{{ route('category.index',['category_id'=>$video->id]) }}">{{ $video->name }}</a></li>
		@else
			<a class="dropdown-item text-left"
			   href="{{ route('category.index',['category_id'=>$video->id]) }}">{{ $video->title_en }}</a>
		@endif
	@endforeach
</ul>

web.php

Route::get('/videos/category/{category_id}', '[email protected]')->name('category.video');

CategoryController.php public function video(Category $category) { $categories = $category->videos()->paginate(25); //dd($categories); return view('Home.categories.videos', compact('categories')); }

videos.blade.php

@extends('Home.master')

@section('contents')
    <div class="bg-white">
        @foreach($categories as $item)

            <div class="container mt-5 mb-5">
                <div class="row">
                    <div class="col-md-2">
                        <p><img src="{{ asset('public/images/products/'.$item->image) }}" class="img-fluid"></p>
                        <h5 class="text-center"><a href="{{ $item->path() }}">{{ $item->title }}</a></h5>
                    </div>
                </div>
            </div>
        @endforeach
    </div>
@endsection

When I type address of http://localhost:8000/fa/videos/category/39. I don't see anything. I see the white screen.

And When I wrote in controller dd($categories); I see this message.

LengthAwarePaginator {#748 ▼
  #total: 0
  #lastPage: 1
  #items: Collection {#747 ▼
	#items: []
  }
  #perPage: 25
  #currentPage: 1
  #path: "http://localhost:8000/fa/videos/category/43"
  #query: []
  #fragment: null
  #pageName: "page"
  +onEachSide: 3
  #options: array:2 [▼
	"path" => "http://localhost:8000/fa/videos/category/43"
	"pageName" => "page"
  ]
}

category_video:

category_video

Mar
13
2 months ago
Mar
05
2 months ago
Activity icon

Replied to RouteServiceProvider.php Redirect() Not Working

I asked why redirect() in RouteServiceProvider not working. answer my question.

Activity icon

Replied to RouteServiceProvider.php Redirect() Not Working

I changed web.php.

$locale = app()->getLocale();

if (redirect('/')) {
    Route::view('/', 'index');
}

Route::get('/'.$locale, '[email protected]')->name('home');
Mar
04
2 months ago
Activity icon

Replied to RouteServiceProvider.php Redirect() Not Working

When I open http://localhost:8000 and http://localhost:8000/en/galleries it open well. And when I open home page http://localhost:8000/en it did not work. it show 404 | Not found`

Activity icon

Started a new Conversation RouteServiceProvider.php Redirect() Not Working

My project is 2 language . I want to select a lang in home page. But I did not solve my problem. I changed code in RouteServiceProvider.php file but it did not solve my problem.

I went for bilinguals, but the problem is in choosing languages ​​on the home page like the site.

What I changed is the following code, but nothing happened to me when I clicked on the English link.

protected function mapWebRoutes()
{
    if (redirect('/')) {
        Route::middleware('web')
            ->namespace($this->namespace)
            ->group(base_path('routes/web.php'));
    }
    else
    {
        $locale = request()->segment(1);
        app()->setLocale($locale);
        Route::middleware('web')
            ->namespace($this->namespace)
            ->prefix($locale)
            ->group(base_path('routes/web.php'));
    }

}

Kernel.php

protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\Language::class,
        .....
    ],
];

Language.php

public function handle($request, Closure $next)
{
    $local = $request->segment(1);
    if (!array_key_exists($local, config('app.locales'))){
        $segments = $request->segments();
        $segments[0] = config('app.fallback_locale');
        return redirect(implode('/', $segments));
    }
    app()->setLocale($local);
    return $next($request);
}

web.php

Route::view('/', 'index');

index.blade.php

<!doctype html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link type="text/css" rel="stylesheet" href="{{ asset('public/assets/lib/bootstrap-4.3.1-dist/bootstrap-rtl.min.css') }}">
    <link type="text/css" rel="stylesheet" href="{{ asset('public/assets/css/style.css') }}"/>
    <title>Select your lang</title>
</head>
<body>
    <div class="container">
        <a href="/ar">Arabic</a>
        <a href="/fa">Farsi</a>
        <a href="/en">English</a>
    </div>
</body>
</html>

Why redirect() in RouteServiceProvider not working.

Activity icon

Replied to RouteServiceProvider.php Not Working

Answer my question

Activity icon

Started a new Conversation RouteServiceProvider.php Not Working

My project is 2 language . I followed https://laracasts.com/discuss/channels/laravel/how-to-select-a-language-in-fron-page-1 . I want to select a lang in home page. But I did not solve my problem. I changed code in RouteServiceProvider.php file but it did not solve my problem.

protected function mapWebRoutes()
{
    if (redirect('/')) {
        Route::middleware('web')
            ->namespace($this->namespace)
            ->group(base_path('routes/web.php'));
    }
    else
    {
        $locale = request()->segment(1);
        app()->setLocale($locale);
        Route::middleware('web')
            ->namespace($this->namespace)
            ->prefix($locale)
            ->group(base_path('routes/web.php'));
    }

}

Why redirect() in RouteServiceProvider not working.

Mar
02
2 months ago
Activity icon

Started a new Conversation Too Few Arguments To Function App\Providers\RouteServiceProvider::mapWebRoutes(), 0 Passed In C:\xampp\htdocs\urmiahardware\blog\app\Providers\RouteServiceProvider.php On Line 71 And Exactly 1 Expected

How to select a language in fron page?

I went for bilinguals, but the problem is in choosing languages ​​on the home page like the site.

What I changed is the following code, but nothing happened to me when I clicked on the English link.

app/Providers/RouteServiceProvider.php

    protected function mapWebRoutes($request)
    {
        $local = request()->segment(1);//IN
        app()->setLocale($local);//IN
        $local = $request->segment(1);
        if (!array_key_exists($local, config('app.locales'))){
            $segments = $request->segments();
            $segments[0] = config('app.fallback_locale');
            return redirect(implode('/', $segments));
        }
        app()->setLocale($local);

        Route::middleware('web')
            ->namespace($this->namespace)
            ->prefix($local)//IN
            ->group(base_path('routes/web.php'));
    }

web.php

Route::view('/', 'index');

index.blade.php

<!doctype html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link type="text/css" rel="stylesheet" href="{{ asset('public/assets/lib/bootstrap-4.3.1-dist/bootstrap-rtl.min.css') }}">
    <link type="text/css" rel="stylesheet" href="{{ asset('public/assets/css/style.css') }}"/>
    <title>Select your lang</title>
</head>
<body>
    <div class="container">
        <a href="/ar">Arabic</a>
        <a href="/fa">Farsi</a>
        <a href="/en">English</a>
    </div>
</body>
</html>

But I get this error...

Too few arguments to function App\Providers\RouteServiceProvider::mapWebRoutes(), 0 passed in C:\xampp\htdocs\urmiahardware\blog\app\Providers\RouteServiceProvider.php on line 71 and exactly 1 expected

Mar
01
2 months ago
Activity icon

Replied to How To Select A Language In Fron Page?

I see this message. When I go to front page

      404 | Not Found
Activity icon

Started a new Conversation How To Select A Language In Fron Page?

I went for bilinguals, but the problem is in choosing languages ​​on the home page like the site.

What I changed is the following code, but nothing happened to me when I clicked on the English link.

Kernel.php

protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\Language::class,
        .....
    ],
];

Language.php

public function handle($request, Closure $next)
{
    $local = $request->segment(1);
    if (!array_key_exists($local, config('app.locales'))){
        $segments = $request->segments();
        $segments[0] = config('app.fallback_locale');
        return redirect(implode('/', $segments));
    }
    app()->setLocale($local);
    return $next($request);
}

web.php

Route::view('/', 'index');

index.blade.php

<!doctype html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link type="text/css" rel="stylesheet" href="{{ asset('public/assets/lib/bootstrap-4.3.1-dist/bootstrap-rtl.min.css') }}">
    <link type="text/css" rel="stylesheet" href="{{ asset('public/assets/css/style.css') }}"/>
    <title>Select your lang</title>
</head>
<body>
    <div class="container">
        <a href="/ar">Arabic</a>
        <a href="/fa">Farsi</a>
        <a href="/en">English</a>
    </div>
</body>
</html>
Feb
19
3 months ago
Activity icon

Replied to Property [id] Does Not Exist On This Collection Instance.

This...

Property [id] does not exist on this collection instance. (View: C:\xampp\htdocs\sites\blog\resources\views\Home\galleries.blade.php)

Activity icon

Replied to Property [id] Does Not Exist On This Collection Instance.

I get this error again

Property [id] does not exist on this collection instance.

Activity icon

Replied to Property [id] Does Not Exist On This Collection Instance.

I created model of Gallery and Category already.

Activity icon

Replied to Property [id] Does Not Exist On This Collection Instance.

I get this error.

Call to undefined relationship [category] on model [App\Gallery].

Activity icon

Started a new Conversation Property [id] Does Not Exist On This Collection Instance.

Look at my codes and I have three tables,

  • galleries
  • categories
  • category_gallery

Gallery.php

public function categories()
{
    return $this->belongsToMany(Category::class);
}

GalleryController.php

public function gallery()
{
    $galleries = Gallery::whereNotNull('image')->latest()->paginate(25);
    $categories = Category::where('parent_id', 42)->with('galleries')->get();
    return view('Home.galleries', compact('galleries', 'categories'));
}

galleries.blade.php

 {{ dd($gallery->categories->id) }}

I get this error

Property [id] does not exist on this collection instance.

Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

Is there anyone who can answer my question?

Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

What should I do now? Help please.

Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

When I click a button.

Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

I changed last your post but It is not starting to use isotopes now ...

Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

Yes, But somewhere it shows a bad image ,

Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

Yes But somewhere it shows a bad image , I changed this

<script>
    $('.nav-item .nav-link').trigger('click');
    $('.nav-item .nav-link').on('click', function (e) {
        e.preventDefault();
        var id = $(this).attr('id');

        $(document).ready( function() {
            $('#pills-tabContent').isotope();
        });
    })
</script>
Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

I see show alert

    $('.nav-item .nav-link').on('click', function (e) {
        e.preventDefault();
        alert('hello');
Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

What should I do now? Help please.

Activity icon

Replied to How To Create Protfolo With Isotope With Laravel

No, There is not any errors.

console