nhayder

nhayder

Member Since 1 Year Ago

Doha

Experience Points
43,200
Total
Experience

1,800 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
305
Lessons
Completed
Best Reply Awards
2
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.

Level 9
43,200 XP
Oct
21
1 day ago
Activity icon

Started a new Conversation Looking For FREE Vue Transition Library, Any Recommendations ???

Hi, i'm sure a lot of you are already vue css transition library. just like me i've been searching all over the place for reliable css transition library.

any recommendations ???

Oct
11
1 week ago
Activity icon

Replied to View Composer Not Finding Blade File

filename has the blade.php extension os that is not the problem.

As for the 2nd suggestion, the main page is dashboard blade and it includes layouts.navbar.blade.php in the layouts.navbar.blade.php i have another partial partials.comments.new. this particle have the $newComments variable.

My app is loading the main dashboard file with all nested included files.

Oct
10
1 week ago
Activity icon

Replied to View Composer Not Finding Blade File

ok, on the bashboard.blade.php I have the main template.blade.php this includes couple of imports, in particular i have @include('layouts.navbar') inside that one i have partials.comments.new

this is the structure

dashboard.blade.php

@extends('layouts.template')

@section('content')

<div class="content custom-scrollbar">

    //code goes here 

</div>

@endsection

layout.template.blade.php

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <title>{{ config('app.name') }}</title>
</head>

<body>

    <main>

        <div id="wrapper">


                @include('layouts.navbar')

                @yield('content')


        </div>

    </main>

</body>

</html>

layouts.navbar.php

<nav id="toolbar" class="bg-white">

    <div class="row no-gutters align-items-center flex-nowrap">   
             
                @can('comments.view')

                    @include('partials.comments.new') //</----- this is the blade file  i need to load

                @endcan
    </div>

</nav>

hope this helps

Oct
09
1 week ago
Activity icon

Started a new Conversation View Composer Not Finding Blade File

I have new component query on my comment.php model

public static function getNewComponent()
    {
    
        return static::with('user', 'article')

                ->where('status', '=', 1)

                ->orderBy('id', 'desc')
                
                ->paginate(10);

    }

on my App service provider i have this view composer that should keep the $newComments variable available every time the partials.comments.new is loaded.

unfortunately? this is working for me (* )

view()->composer('*', function($view){

    $view->with('newComments', Comment::getNewComponent());

});

this is returning error

view()->composer('partials.comments.new', function($view){

       $view->with('newComments', Comment::getNewComponent());

 });

this is the error

Undefined variable: newComments (View: /Applications/MAMP/htdocs/myapp/resources/views/admin/dashboard/dashboard.blade.php)

the URI partials.comments.new dose exist and i have blade partial available on the folder.

Any ideas what is going on .

Oct
04
2 weeks ago
Activity icon

Started a new Conversation How To Allow Public To View Article With Permission

In my app i have many to many relationship for my articles these are basically are roles, So the admin can choose which role to attach to article.

currently i have this gate function on the ArticleController

if (Gate::denies('articles.view')) {
            
            return view('auth.login');;
        
 }

the gate is doing what is supposed to do? and its working fine so there is no issue with that.

But now i need to add an option that will make the article available to public without registration?

my question is what is the laravel way to achieve this type of permission ????

Any ideas ????

Sep
27
3 weeks ago
Activity icon

Replied to Stuck On How To Paginate Nested Relationship

YES, multiple widgets per page, some of them has articles others don't.

Sep
26
3 weeks ago
Activity icon

Started a new Conversation Stuck On How To Paginate Nested Relationship

it's been a couple of day trying to get my pagination code straight, thought i was told that laravel do not support nested relationship out of the box.

BUT i seriously hope that somebody will has been through this before and he made a fix for this case. because i have 0 solution so far.

Basically i need to paginate articles that are being loaded in widgets with nested relashioship.

this is my code without pagination.

    public static function getPageWidgetsWithArticles($id, $lang)
    {
        $pageWidget = Cache::rememberForever('page-'.$id, function () use ($id,$lang) {
        
            return Widget::with(

                        ['articles' => function ($query) use ($lang) {

                            $query->where('language', '=', $lang);

                        }],

                        'buttons', 'content', 'content.linkedPage', 'content.linkedArticle'
                    )

                    ->where('page_id', '=', $id)

                    ->get();

        });

        return $pageWidget;
    }

the articles function should be paginated and by doing this

['articles' => function ($query) use ($lang) {

        $query->where('language', '=', $lang)->paginate(10);

}],

laravel is not returning any paginated data ????

Has anybody been in this situation before ????? is there is a fix for this ???

Any ideas ???

Sep
25
3 weeks ago
Activity icon

Started a new Conversation Adding Paginated Collection To Eloquent Object

this is getting complicated on my end so excuse the mess in the code, But i'm in a situation where i need to add a paginated list of articles to existing eloquent object. the code lives on the widget.php model as static method like this

    public static function getPageWidgets($id, $lang)
    {
    // this returns the widgets available on the page

        $pageWidget = Cache::rememberForever('page-'.$id, function () use ($id) {
        
            return Widget::with('buttons', 'content')

                    ->where('page_id', '=', $id)

                    ->orderBy('sorting', 'asc')

                    ->get();

        });

    //this returns the articles in a single widget

        $wArticles = Cache::rememberForever('wArticles-'.$id, function () use ($id, $lang) {
        
            return Article::where('category_id', '=', 1)
                    
                    ->orderBy('id', 'desc')

                    ->paginate(10);

        });
        
        return $pageWidget;
    }

i'm trying to add the $wArticles to $pageWidget object to look like this

// this is the widget
[
    {

    fullscreendisabled: false,
    showbuttonsdisabled: false,
    showarrowdisabled: false,
    disablecontentcount: true,
    disablecontentposter: false,
    .... etc ....

    buttons: [ ],
    content: [ ],
    articles: [ ] // <----- i need to add articles to it like this so i can loop through it in blade
    }

]

how can i add my articles collection as shown above

Sep
24
4 weeks ago
Activity icon

Started a new Conversation Adding Paginated Collection To Eloquent Object

this is getting complicated on my end so excuse the mess in the code, But i'm in a situation where i need to add a paginated list of articles to existing eloquent object. the code lives on the widget.php model as static method like this

    public static function getPageWidgets($id, $lang)
    {
    // this returns the widgets available on the page

        $pageWidget = Cache::rememberForever('page-'.$id, function () use ($id) {
        
            return Widget::with('buttons', 'content')

                    ->where('page_id', '=', $id)

                    ->orderBy('sorting', 'asc')

                    ->get();

        });

    //this returns the articles in a single widget

        $wArticles = Cache::rememberForever('wArticles-'.$id, function () use ($id, $lang) {
        
            return Article::where('category_id', '=', 1)
                    
                    ->orderBy('id', 'desc')

                    ->paginate(10);

        });
        
        return $pageWidget;
    }

i'm trying to add the $wArticles to $pageWidget object to look like this

// this is the widget
[
    {

    fullscreendisabled: false,
    showbuttonsdisabled: false,
    showarrowdisabled: false,
    disablecontentcount: true,
    disablecontentposter: false,
    .... etc ....

    buttons: [ ],
    content: [ ],
    articles: [ ] // <----- i need to add articles to it like this so i can loop through it in blade
    }

]

how can i add my articles collection as shown above

Activity icon

Replied to How To Paginate A Relationship Inside Eloquent Model

@snapey hey how are you, ...

Your comment is very clear, I was trying to understand if it's possible to paginate a nested relationship or not. will do a seperate variable for the paginated collection, that will definitely work.

So glad you showed up :-), Thanks

Activity icon

Replied to How To Paginate A Relationship Inside Eloquent Model

i'm getting same error for all cases, that because the links function is not available ???

Method Illuminate\Database\Eloquent\Collection::links does not exist
Activity icon

Replied to How To Paginate A Relationship Inside Eloquent Model

i think now we are on the same page, But not sure how to implement your code with mine,

i have this

    public static function getPageWidgets($id, $lang)
    {
        $pageWidget = Cache::rememberForever('page-'.$id, function () use ($id,$lang) {
        
            return Widget::with(

                        ['wsubcats','buttons', 'content', 'content.linkedPage', 'content.linkedArticle','articles' => function ($query) use ($lang) {

                            $query->where('language', '=', $lang)->paginate(15);

                        }]

                    )

                    ->where('page_id', '=', $id)

                    ->orderBy('sorting', 'asc')

                    ->get();

        });

        return $pageWidget;
    }

but when i dd($widget->articles) i can't see any pagination is happening.

So how to implement your code with maine ??? any ideas

Activity icon

Replied to How To Paginate A Relationship Inside Eloquent Model

just noticed that the code above is not returining pagionated data when i dd($widget->article);

So basically the pagionation is not taking place ????

Activity icon

Replied to How To Paginate A Relationship Inside Eloquent Model

can you show some code please

Activity icon

Replied to How To Paginate A Relationship Inside Eloquent Model

@sti3bas i've gone through your link, Unfortunately it's very difficult to understand the documentation for a beginner like me, Are you familiar for any tutorial that cover this type of pagination

Activity icon

Started a new Conversation How To Paginate A Relationship Inside Eloquent Model

i'm trying to paginate list of articles inside my app news page withen main query like this

    public static function getPageWidgets($id, $lang)
    {
        $pageWidget = Cache::rememberForever('page-'.$id, function () use ($id,$lang) {
        
            return Widget::with(

                        ['wsubcats','buttons', 'content', 'content.linkedPage', 'content.linkedArticle','articles' => function ($query) use ($lang) {

                            $query->where('language', '=', $lang)->paginate(15);

                        }]

                    )

                    ->where('page_id', '=', $id)

                    ->orderBy('sorting', 'asc')

                    ->get();

        });

        return $pageWidget;
    }

in blade i need to show pagination btns so i'm doing this

{{ $widget->articles->links() }}

this is the error i'm getting

Method Illuminate\Database\Eloquent\Collection::links does not exist. (View: /Applications/MAMP/htdocs/resources/views/includes/dynamicList.blade.php) (View: /Applications/MAMP/htdocs/resources/views/includes/dynamicList.blade.php) (View: /Applications/MAMP/htdocs/resources/views/includes/dynamicList.blade.php)

any idea on how to paginate this type of query

Sep
18
1 month ago
Activity icon

Started a new Conversation How To Validate Slug On Update

i have article crud from with article slug text field, when the article is created i'm validating the article slug like this

'slug' => 'required|string|max:255|unique:categories',

The issue that i'm having is when i attempting to update the form without changing the slug, the code above is returning

The slug has already been taken

Tthat is totally expected because the unique:categories is supposed to do that?

My question is??? What is the laravel way to handle this type of validation.

thanx

Sep
17
1 month ago
Activity icon

Started a new Conversation Non-latin Rtl Script Is Reversing The URL Of The Page ?

Hi,

i noticed that when using full translated url for routed page i'm getting a reversed URL when executing the page.

in english version of the site i have this page

https://mywebsite/en/blog/sports/this-is-the-slug-for-the-view

For other RTL languages i'm translating the entire url including the blog + sport+ article slug. for better SEO results,

Unfortunately, When doing that i'm getting a reversed URL because the language is an RTL language

//this is how my arabic url reads in english 
https://mywebsite/this-is-the-slug-for-the-view/sports/blog // <--- reversed URL ?.

NOTE: i typed the arabic URL in english so you can read it and see the problem the original route is written in arabic which is RTL language

any idea on how to fix this.

Sep
05
1 month ago
Activity icon

Replied to How To Chain Relationships With Query Builder

@ftiersch i was able to get all the data like this

        $widgets = Widget::with(['buttons', 'content', 'content.linkedPage', 'content.linkedArticle','category.articles' => function ($query) {

                        $query->where('language', 'ar')
                        ->with('editor', 'poster');

                    }]


                )

            ->where('page_id', '=', $id)

            ->orderBy('sorting', 'asc')
            
            ->get();

        return $widgets;

Thanx man

Activity icon

Replied to How To Chain Relationships With Query Builder

hey @ftiersch how is your day,

yes it worked and i can see the editor and poster data, which is a great improvement.

but still i lost the rest of the relationships (buttons, content, ... etc)

        $widgets = Widget::with(
                
                    ['category.articles' => function ($query) {

                        $query->where('language', 'en')
                        ->with('editor', 'poster');

                    }],

                    'buttons', 'content', 'content.linkedPage', 'content.linkedArticle'

                )

            ->where('page_id', '=', $id)

            ->orderBy('sorting', 'asc')
            
            ->get();

        return $widgets;

any ideas

Activity icon

Started a new Conversation How To Chain Relationships With Query Builder

i'm trying to get editor and poster data for every article in single query, unfortunately i'm not getting these data on the final query.

this is my code

    public function widgets($id = null)
    {

        if($id){

            $pageID = $id;

        }else{

            $id = 1;

        }

        $widgets = Widget::with(
                
                    ['category.articles' => function ($query) {

                        $query->where('language', 'en');

                    }],

                    'category.articles.editor',

                    'category.articles.poster',

                    'buttons', 'content', 'content.linkedPage', 'content.linkedArticle'

                )

            ->where('page_id', '=', $id)

            ->orderBy('sorting', 'asc')
            
            ->get();

        return $widgets;

    }

After running the code i'm not returning the editors neither the poster data.

is there is a better way on how to this type of query.

any ideas ???

Sep
02
1 month ago
Activity icon

Replied to How To Passing Dynamic Parameters To HasMany Relationship

@ftiersch thank you, your input was very helpful and i was able to the correct $lang value from DB.

i think it's working just fine now.

it looks like thing working fine. :-)

Thank you.

Activity icon

Replied to How To Passing Dynamic Parameters To HasMany Relationship

yes when an editor create a new article he is restricted to choose article language, to its configurable value.

from your example i can see that you are passing the language parameter in totally different way, whitch might work in my case,

But not sure where did line come from

$category->articles()->where('language','=', 'fr')->get();

this is the function that i'm using to fetch articles

    public static function getPageWidgets($id, $lang)
    {
        $pageWidget = Widget::with(

                        'category.selectedsubcategory.articles',

                    )

                    ->where('page_id', '=', $id)

                    ->get();

        return $pageWidget;
    }

i'm not sure how can i implement your code on method above, but i can pass the $lang to the function like example above ($lang might be fr,en,ar, .... etc)

Activity icon

Started a new Conversation How To Passing Dynamic Parameters To HasMany Relationship

i'm in this situation where i have widget has many articles relationship,

this is my controller

    public function page($slug = null)
    {

        if($slug){

            $id = Page::getPageID($slug);

        }else{
            
            $id = Page::getHomePage();

        } 
            
        $pageWidget = Widget::getPageWidgets($id);

        return view('public.welcome', compact( 'pageWidget'));

    }

this is the getPageWidgets function where i'm loading all articles related to this page

    public static function getPageWidgets($id)
    {
        $pageWidget = Widget::with(

                        'category.selectedsubcategory.articles',

                    )

                    ->where('page_id', '=', $id)

                    ->get();

        return $pageWidget;
    }

// this is the article relationship that loads the articles,

    public function articles()
    {
        return $this->hasMany(Article::class, 'id', 'contentcategory') 

            ->where('language', '=', 'en') // <---- the article local should be dynamic

            ->orderBy('id', 'desc')

            ->take(12);

    }

i need to load articles according to page language, The relationship above will load en articles only.

so how can pass parameters like en,fr,de, ... to the article relationship above.

any ideas.

Aug
25
1 month ago
Activity icon

Started a new Conversation What Is The Laravel Way To Keep On Maximum Of 5 Records On DB

Hi,

i'm storing user IP on database every time he logs in to his account, Clearly that might exceed hundreds of records for each user.

So as you might expect, Data should be limited to a certain number of records only (5 MAX records containing user ip is pretty good number).

So my question? What is the laravel way to keeping records up of 5 every time ????

Dos laravel have this type of functionality onboard, ????

Any ideas??

Aug
21
2 months ago
Activity icon

Started a new Conversation What Is The Path To Storage Directory To Upload Files Into

I have a media folder under /App/storage/app/media where i'm planning to store all my uploaded files into. but i need the path to that folder ??? (not to /App/public where laravel normally stores files to public).

from my search i found this ridiculous solution? ironically it worked :-)

$path = Storage::disk('media')->getDriver()->getAdapter()->getPathPrefix().strtolower($newimage->id.'/md-'.$fileName);

// where $newimage->id.'/md-'.$fileName is my encoded file name

I'm sure there is a better way to get the Path to the media folder?

Any Ideas ?????

Aug
20
2 months ago
Activity icon

Started a new Conversation How To Chain Eager Load Articles According To Categories And Subcategories

i have multiple widgets on the page i'm giving the user the ability to load articles according to his choice, by selecting category subcategory then hitting the submit button.

i'm having some difficulties on how to make a this relationship work.

// these are the widgets

widget 1
    - id
    - Politics
    - contentcategory // this is the main category
    - contentsubcategory // this is the sub-cateogry

widget 2
    - id
    - sport
    - contentcategory 
    - contentsubcategory

widget 3
    - id
    - lifestyle
    - contentcategory 
    - contentsubcategory

The main and sub category are save into the widget table using simple form, now i need to perform the relationship to fetch the articles.

article 1
    - id
    - title
    - category_id // this is the article main category
    - subcategory_id // this is the article sub-cateogry

article 2
    - id
    - title
    - category_id 
    - subcategory_id

article 3
    - id
    - title
    - category_id 
    - subcategory_id

i'm trying to get this type of relationship

$widget->category->subcategory->articles;

widget has one category -> category has many subs -> sub has many articles 

To achieve my purpose i need to make a relationship between these table so the widget main cat+subcat matches the article main cat +subcat.

How to perform this type of relationship, any idea ?????

Aug
13
2 months ago
Activity icon

Replied to How To Use Laravel Localization In Vue

@morpheus7 thank you i didn't know about that package till you brought it up, i will definitely check it soon :-)

Activity icon

Replied to How To Use Laravel Localization In Vue

Thank you for the time you took for explanation ? it looks like it will definitely work but i'm not sure if this is the recommended way to do that.

Aug
12
2 months ago
Activity icon

Started a new Conversation How To Use Laravel Localization In Vue

i'm using vuex, vue and laravel 5.8 on my multilingual app, i'm at a point to add localization to my vue component.

i didn't started yet but i'm checking what is the best way to extend laravel localization to some vue component on the app.

any recommendations on this matter ???

Aug
01
2 months ago
Activity icon

Started a new Conversation Testing With Chrome DevTools Returning Medium Vulnerability For [email protected]

i'm getting a [email protected] medium Vulnerability when i tested my laravel app with chrome devTools performance

https://snyk.io/vuln/npm:bootstrap?lh=4.1.0&utm_source=lighthouse&utm_medium=ref&utm_campaign=audit

snap shot available here https://www.dropbox.com/s/2ww6cu8fsq46bzf/Screen%20Shot%202019-08-01%20at%207.28.57%20PM.png?dl=0

anyone else having same issue ??? any fix for it ????

Jul
29
2 months ago
Activity icon

Started a new Conversation Axios Ajax Call Not Working On Safari

I'm fetching data on my app using axios like this


        async saveText({commit}, [id, text, name, wIndex]){

            commit('WORK_ON');

            await axios.put('/api/text', {

                elem: text,

                elemName : name,

                elemId: id,

            })

            .then(function (response) {


                Event.$emit('success'); 

            })

            .catch(function (error) {

                Event.$emit('requestAlertDanger'); 

            });

        },

the code is working fine on chrome but today i was testing the app on safari and was surprised that code is not working.

Any ideas why that is??? How do fix this issue

Jul
27
2 months ago
Activity icon

Replied to Count Logged In Users

this solved it

function countOnlineUsers() {

    // get all users from cache
    $cachedUsers = json_decode(Cache::get('isOnline', []), true);
    
    $count = count($cachedUsers);

    return $count;
}

Activity icon

Started a new Conversation Count Logged In Users

I have a middleware that will add user to array every time a user login to his account

    public function handle($request, Closure $next)
    {
        if(Auth::check()) {
            
            $lastSeen = Carbon::now()->format('y-m-d H:i:s');

            $onlineUsers = json_decode(Cache::get('isOnline', '{}'), true);

            $onlineUsers[ Auth::id() ] = $lastSeen;

            Cache::put('isOnline', json_encode($onlineUsers), 60); // store for 2 minutes

        }

        return $next($request);
    }

Now i need to check how many users are in that array from blade template file ????

Any ideas on how to do this ????

Jul
22
3 months ago
Activity icon

Replied to Spatie/laravel-sitemap Creating Empty Sitemap.xml

@cronix Yah, :-) worked after i uploaded the site to the internet, Thanx

Jul
21
3 months ago
Activity icon

Replied to Spatie/laravel-sitemap Creating Empty Sitemap.xml

@bobbybouwmann actually the app.url was not matching so i changed is like this

Route::get('/sitemap', function(){

    SitemapGenerator::create('http://127.0.0.1:8000')->writeToFile('sitemap.xml');

    return 'Sitemap generated';

});

After the that change the file now need almost 2 minutes for be created and its still empty?

// this is the content of the file after its being created
<?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
</urlset>

@snapey to answer you questions, 1- no i'm not using a command the file creation is directly on the web.php file 2- i'm running the app on localhost, but the files is being created every time 3- i'm using laravel 5.8 4- yes all my routes are in web.php

Activity icon

Started a new Conversation Spatie/laravel-sitemap Creating Empty Sitemap.xml

i'm using spatie/laravel-sitemap to generate sitemap.xml file dynamically, The package is not creating the site map but its always empty.

packager usrl : https://github.com/spatie/laravel-sitemap

created sitemap.xml

// this is what im getting every time
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
</urlset>

this is how im generating the file???

SitemapGenerator::create(config('app.url'))->writeToFile(public_path('sitemap.txt'));

if there is anyone who is using this package? can you see what is the problem

All the best

Jul
20
3 months ago
Activity icon

Started a new Conversation Can't Paginate Search Result Records?

this is the form

<form action="{{route('rp')}}" method="GET" role="search" enctype="multipart/form-data">
    @csrf
    <input type="text" name="search" class="search-input form-control" placeholder="@lang('translation.search')" required="true"/>

</form>

and i have this route to execute the search

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

in my controller


    public function resultPage(Request $request)
    {


        $request->validate([

            'search' => 'required|string|min:3',

        ]);
        

        $query = User::query();

        $columns = ['firstname','familyname', 'email', 'language', 'adminnote','gender','address1','address2','company','city','postalcode','phone'];

        foreach($columns as $column){

            $query->orWhere($column, 'LIKE', '%' . $request->search . '%');
        }

        $results = $query->paginate(25);

        return view('admin.search', compact('results'));
        
    }

at the same time i'm using links() function to paginate results


@foreach($results as $user)
    
    // do something

@endif

{{ $results->links() }}

this is what i'm getting on the browser when submitting search from


http://127.0.0.1:8000/en/admin/rp?_token=YDZrO7i6h0ao7OSokwmttqL8YoONFNqf6z9pn9Cq&search=johan

when hover over the pagination button i'm getting these


http://127.0.0.1:8000/en/admin/rp?page=2 // and page=3 + 5 + 10  etc

the problem is that pationation is not working it basically stays on same page even after i click the next button

what seems to be the problem

?????

Jul
15
3 months ago
Activity icon

Started a new Conversation Uncaching Iframe Data Not Working

in my app a user can preview his personal page as it looks on phone and tablet and desktop computer , i'm loading a view inside and iframe to simulate multiple screen sizes.

<iframe src="/"></iframe> // this loads personal page of user as phone size

the iframe is doing its job perfectly and working fine, until a user change some settings on his personal page, then when he tries to preview it? iframe is still shows previous information inside the iframe.

the personal page has some caching already so using axios i'm clearing the cached files directly from controller.

Artisan::call('cache:clear');

The cache files are removed and axios is working as expected but, unfortunately, iframe is still showing old data every time, The only way i can see the new changes is when i refresh the page.

it looks like cache:clear is not uncaching the iframe data as expected, until i refresh the page.

so how to force my iframe to clear cached data without refreshing the page

any ideas???

Jul
14
3 months ago
Activity icon

Started a new Conversation Select Proper Value From Array Dynamically

in my app i have page footer are where it supposed to show copyright message dynamically according the users reading language.

the copyright data with multiple languages values is already stored in array that looks like this

// copyrights array
{
id: 1,
  de: "Alle Rechte vorbehalten - 2019.",
  en: "All rights reserved - 2019",
  es: "Todos los derechos reservados - 2019.",
  fr: "Tous droits réservés - 2019.",
}

from my page footer component i can get the current language from array like this

<p v-html="copyrights.en"></p> // --> this will show footer copyright message in english

to get the current page language i have stored it on a locale variable and it returns the current reading language extension (en, fr, it ,.....)

console.log(locale) // returns proper value for example en or de, ...

so now i can choose which message to show on page footer dynamically because i have the current page locale and the multilanguage copyright array with all data i need

so i made a function that will return the correct data

<p v-html="message()"></p> // localized message should be shown here

// this is the function
    message : function(){

      var locale = this.pagesettings.language_id;
      return this.copyrights+locale; // is returning error but copyrights.en is returning correct data

    },

can someone please write the correct code for my dynamic copyright function.

thanx

Activity icon

Replied to Sessioned Flash Is Displayed On All Forms On Same Page

i will definitely give it a try

Activity icon

Replied to Sessioned Flash Is Displayed On All Forms On Same Page

i'm fully aware of these solutions but my initial question was on how to validate + store + show flashed massage for every form separately without affecting each other???

Activity icon

Replied to Sessioned Flash Is Displayed On All Forms On Same Page

login form on the bottom of the page and another one on popup a modal.

Activity icon

Started a new Conversation Sessioned Flash Is Displayed On All Forms On Same Page

i have a page with 2 exact forms on same page but they have different css design, unfortunately i'm not being able to differentiate them from each other that resulted to get same validation on the form.

Example when a user fill up a form the laravel is requesting the user to fillup the other page.

<form action="{{route('account')}}" method="POST" enctype="multipart/form-data">

    // email +password

</form>

<form action="{{route('account')}}" method="POST" enctype="multipart/form-data">

    // email +password

</form>

In addition to that, when form data is store the session flash data is also displayed on both form ???

Session::flash('loggedInSuccessMsg');

Any solution for this issue?

Jul
09
3 months ago
Activity icon

Replied to Call To A Member Function SetCookie() On Null

ok just found the fix

<?php

namespace App\Http\Middleware;

use Closure;
use Auth;

class RedirectBlockedAccounts
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        if (Auth::check()){

            if(Auth::user()->status == 3)
            {

                Auth::logout();
                
                return redirect()->route('errors.block');

            }

        }
        
        return $next($request);

    }
}

Activity icon

Started a new Conversation Call To A Member Function SetCookie() On Null

Hey,

I have a middleware that forces blocked users when they are detected,

<?php

namespace App\Http\Middleware;

use Closure;
use Auth;

class RedirectBlockedAccounts
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {


            if(Auth::user()->status == 3)
            {

                Auth::logout();
                
                return view('errors.block');

            }

        
        return $next($request);

    }
}

the implementation above is returning error

Call to a member function setCookie() on null

is there is a fix for that?

Any Ideas

Jul
05
3 months ago
Activity icon

Replied to Customer Command Is Inserting Data Correctly To DB

i can't believe i didn't check the $fillable array, OH

i need to have a very very strong coffee today :-)

Thanks man.

Activity icon

Replied to Customer Command Is Inserting Data Correctly To DB

@snapey It's really complicated to explain why at this point, But i'm hoping that you examine the code so i can move on with my project :-).

Activity icon

Replied to Customer Command Is Inserting Data Correctly To DB

Why your saying that?? do you have better solution??