pickab00

Experience

3,170

0 Best Reply Awards

  • Member Since 6 Months Ago
  • 1 Lesson Completed
  • 0 Favorites

24th June, 2018

pickab00 left a reply on A Better Solution For Page Visit Counter • 1 day ago

Thank you. I will surely head on there and have a look. As for google analytics, can I track the drunamic pages? As in post by its id. Id being a page.

The counter I linked, I can modify it to generate reports from the backend as the user desires. Just wanted to see if there was a way I could track it without a third party and what were my chances of making it fool proof.

Sorry I do not have enough experience nor have I looked that deep in to google analytics and intergration with laravel. But you were a lot of help and the answers were straight forward and thank you for that.

pickab00 left a reply on A Better Solution For Page Visit Counter • 1 day ago

Well the idea is pretty straightforward and simple. I want to be able to track the amount of people visiting my website. Dynamic web pages. And of course like you mentioned, the popularity. Now you are right on that point. Google is a third party and therefore it will be hard to take their data and manipulate my views accordingly. Lets say, I won’t be able to display the most viewed posts.

That is basically it. Page/visitor counter. So that I can determine the popularity. And also in general the whol website visit tracking.

pickab00 left a reply on A Better Solution For Page Visit Counter • 1 day ago

@rosswintle So what about google analytics? Is it any good or better at tracking pages and website in general? The package mentioned on the question seems to work pretty well.

pickab00 left a reply on A Better Solution For Page Visit Counter • 1 day ago

@rosswintle Yes that is exactly what I am looking for. Something which will apply for all decices on the same IP as well. Could you please recommend one. And you are right. Incognito and private mode clears cookies onces it is closed and reopened (browser I mean)

pickab00 left a reply on Visiting Another Website • 1 day ago

use anchor tag on you blade template. Normal HTML.

<a href="https://www.google.com" target="_blank">Google</a>

target="_blank" opens the link in a new tab.

pickab00 started a new conversation Request To Change The Post Replies To Show The Latest First On Laracasts • 1 day ago

I know this will make things harder but can I just put it here as an enhancement or a future update perhaps? It will be difficult for people to see the latest posts first (Sometimes). So my suggestion is, keep a button to order the replies of the comments by either latest replies first or the normal current way.

Just another suggestion :)

pickab00 left a reply on Route Showing Strange • 1 day ago

Can you please post your web.php file content. Also, please use 4 indentation for codes (give 4 spaces before your code)

pickab00 left a reply on Redirect()->route('login'); Not Working In Laravel 5.4 • 1 day ago

can you try and test

return redirect('perhap/.elsewhere');

Also, is that supposed to be else statement just in case the first one fails? Try wrapping it inside the else{} closure.

Also, Whats $CreateNewAccount->createFreeEvent();

pickab00 left a reply on Where Are You All From? • 1 day ago

The smallest country on the world map :)

pickab00 started a new conversation A Better Solution For Page Visit Counter • 1 day ago

Ok. first and foremost, there are tons of packages out there. I have tried almost all of the packages and some are impressive, while others are either outdated and no longer in production or they all have one common big flaw. Some packages do use caching/cookies to track the IP. And then there are some which does not utilize cookies for IP fallback.

However, there was one package which caught my attention (for anyone who is looking for a good package). https://github.com/Kryptonit3/Counter This package is both usable and manageable. However, like everything out there, there is one big flaw. The incognito mode. Now in private/incognito mode, the cache, cookies and everything else is cleared and started fresh. So the page counter get 1 hit per refresh/revisit.

Is there any better or best package for counting page view counter which will hit one count per page per IP (per page meaning dynamic pages included).

22nd June, 2018

pickab00 left a reply on How To Save Images Related To That Post After Adding The Post • 2 days ago

@Yorki This is what I have updated. And this is my update function:

 public function update(Request $request, $id)
 {
    
    $article = Article::findOrFail($id);

    $article->title = $request->title;
    $article->sub_title = $request->sub_title;
    $article->category_id = $request->category;
    $article->maincontent = $request->maincontent;

    if ($file = $request->file('image')){

        $name = $file->getClientOriginalName();

        $rename = str_random(10) . $name;

        $file->move('images/articles/dhivehi/main', $rename);

        $article->image = $rename;

     }

    $article->update();

    foreach ($request->images as $image){

        $imageModel = Image::where('article_id', '=', $id)->get();

        $name = $image->getClientOriginalName();
        $rename = str_random(10) . $name;
        $image->move('images/articles/dhivehi',$rename);
        $imageModel->admin_id = Auth::guard('admin')->user()->id;
        $imageModel->name = $rename;
        $imageModel->save();

        $article->images()->update($imageModel);
        }


    return redirect()->back();

  }

pickab00 left a reply on How To Save Images Related To That Post After Adding The Post • 2 days ago

@Yorki Thanks. This works. But if I were to edit/Delete the Images linked to the article, what should I do?

pickab00 started a new conversation How To Save Images Related To That Post After Adding The Post • 2 days ago

I have a articles table and images table. Article model and Image model. images table has article_id. Here is the model:

Article:

public function images(){
    return $this->hasMany('App\Image');
    }

Image:

public function article(){
    return $this->belongsTo('App\Article');
    }

Here is my controller:

public function store(Request $request)
{
    $article = new Article;

    $article->url = mt_rand(100000, 999999);
    $article->admin_id = Auth::guard('admin')->user()->id;
    $article->title = $request->title;
    $article->sub_title = $request->sub_title;
    $article->category_id = $request->category;
    $article->maincontent = $request->maincontent;
    $article->lang = '1';
    $article->image = $request->image; //ignore this for now
    $article->approved = '0';

    $article->save();

    $saveImages = new Image;
    foreach ($request->images as $image){
        $article->images()->saveMany([$image]);
    }


    return redirect()->back();

    }

I have a image html input field and images field. image adds a single image but images takes in an array of images. Now how can I add the Images from the array to the images table with the added article id?

pickab00 left a reply on Quick Question: About Relationship • 3 days ago

@36864 Thank you for the answer. A definite thumbs up

pickab00 left a reply on Quick Question: About Relationship • 3 days ago

@Snapey Ok got it. Now its clear. So many to many relationships will have tags and posts. And what you explained above. Correct? Thanks a bunch

Now I am not sure which answerto accept XD

pickab00 left a reply on Quick Question: About Relationship • 3 days ago

@36864 You saved the day. This was well explained. Now one last question. What do you mean by this. " If the relationship is meant to fetch a collection of models, it will try to singularize the method name." What do you mean by that?

Can you please give an example of your statement you meant by "a collection of models"

pickab00 left a reply on Quick Question: About Relationship • 3 days ago

But like I mentioned, admin_id does not work. However, admins_id does work. Am I doing something wrong here?

pickab00 started a new conversation Quick Question: About Relationship • 3 days ago

I get this confused a lot of the times.

So I have two models. Admin and Tag. It is singular. Not plural. When I migrate the tables, it becomes admins and tags. So lets say I have this relationship defined on the Tag model:

public function admins(){
    return $this->belongsTo('App\Admin');
    }

Now the thing is, I am not able to get the relation ship with this $tag = Tag::with('admins')->get(); This happens because my tags table is having the column name as admin_id. So I have to manually define the foreign key and local key. But if I change the column name to admins_id it works without defining the foreign and local key.

So my question is, when naming the related field in a table, do I always have to name it as the table is named? Example:

tags_id users_id admins_id comments_id

All these listed are the names of the tables. Do I have to name the fields like this or singular and not plural. What is the convention?

21st June, 2018

pickab00 left a reply on How To Add Data To Another Table After The Current Data Has Been Added • 3 days ago

@Vilfago is there a better way to do it? Something like sync(). But sync() is for many to many relationships. I am saying this because I want to be able to update it as well. With sync, the second parameter will override any existing data with the relationship if it is set to true.

pickab00 started a new conversation How To Add Data To Another Table After The Current Data Has Been Added • 3 days ago

Ok this question is a bit complicated and I will try to explain it best.

Basically, I have two tables. Gallery table and Galleryimages table. Now the gallery_id is inside of Galleryimages table. With this said, the relationship looks like this.

Galleryimage belongsTo Gallery Gallery hasMany Galleryimage

So basically think of it as this. The gallery will have a name, title and other stuff. But it's images will be stored in Galleryimage.

Now my question is, I have two models. One is Gallery and the other GalleryImage. So how can I add the GalleryImage right after adding a Gallery.

Here is an example for better understanding. This is HTML:

<form method="post" action="[email protected]" enctype="multipart/form-data">
    <input type="text" name="name" />   

    <input type="file" multiple name="images[]" />

    <input type="submit" value="Insert">
</form>

Here is the controller:

$gallery = new Gallery;

$gallery->name = $request->name;

$gallery->save();

//This is where it gets confusing.

I am stuck here. Now I can only add the array of images to the other table (Galleryimage) only once the current data is saved right? Because else I wont have the ID of the Gallery to post it in to Galleryimage table. Because Galleryimage has a column named gallery_id. So how can I now add the array of images linking it to the newly created gallery item?

pickab00 started a new conversation How To Take Multiple Values From One Column In Laravel • 4 days ago

Ok so the question maybe broad but I will try to explain as best as I can.

Basically I have a “tags” table and a “posts” table. As I am using eloquent, my posts table has a column named named. This column will basically enter the tags tables ta in to the posts tables tables.

What I currently do not get is, how can I fetch the data? Assuming this is my code:

$postsWithTags = Post::with(‘tags’)->get();

And now I could just use a @foreach in my blade and get the column named tag_id data. But here is the thing. If my tag_id column had this data (1, 2, 3, 4), how can I fetch that data and display the actual tag name?

I have a tags table and a posts table. And I am using a single column in posts table named tag_id to store multiple tag id from tags table (this is a summary of what I just explained).

Is there any better ways to achieve this? Do I need to create a separate table? Or stick with this? And how can I take the multiple values from one column which data is something like this (1, 2, 3, 4) and also display the tag name.

13th May, 2018

pickab00 left a reply on How To Use With() Method With Where() • 1 month ago

@Snapey i was looking for @Sergiu17 solution. Gives me all the menus but only the active ones.

This solution works. Thanks

pickab00 started a new conversation How To Use With() Method With Where() • 1 month ago

Here is my controller query:

$menu = Menu::with('pages')->get();

I tried to use $menu = Menu::with('pages')->where('active', '=', '1')->get();

But my active is in pages. So how can i take the pages which has active = 1

thanks a bunch

8th April, 2018

pickab00 started a new conversation Display Related Posts Except For A Specific Post • 2 months ago

As the heading suggests, i want to display the related post except for the one i am reading currently. Here is the code so far:

public function blog_post_single_page($slug, $id){

    $show_blog_post = Blog::findOrFail($id);

    $related_posts = Blog::with('category')->where('blogcategory_id', '=', 
$show_blog_post->blogcategory_id)->get();

    return view('front-end/blog/blog_post_single', compact('show_blog_post', 'related_posts'));

}

I am displaying the related posts on the blog single page view. The thing is, with the above code, i get the currently reading post as well. I know there is an except() in $request/HTTP Request in Laravel. Is there any way i could achieve this?

for better understanding, here is my current result. I have opened a post named 'test post' and it belongs to 'help' category. Now i am displaying related posts by taking posts from db where category is 'help'. the problem with doing so is that the collection outputs the 'test post' as well (which i am currently reading). How can i not show that post?

11th March, 2018

pickab00 left a reply on Cache Input Value When Navigating Through • 3 months ago

@kishanbhatt How can i achieve this with ajax? any ideas to proceed with?

pickab00 started a new conversation Cache Input Value When Navigating Through • 3 months ago

I was wondering if this was possible. Basically, i have a form with a user input. And i was wondering if this could be cached or stored until the user goes back to the page. Lets say that the user input field is in "fill-me" page. And the user filled in the form. And if the user decides to go to the "info" page and come back, the data would still be there until submit button is pressed. Is this possible? How can i achieve this?

Thanks

4th March, 2018

pickab00 started a new conversation Lets Encrypt Singed SSL Cert On Homestead? • 3 months ago

I just wanted to know if this was possible. If it is possible to get a signed certificate (Not self signed) from an authority to run with Homestead. Because I have an application which i don't want to run in an actual server. I would like to just run it on a local computer which will then serve to other devices on the same network. But i have some API which only works with SSL/HTTPS. I have a self signed Cert but the chrome error is coming and i am not able to use the API on chrome.

1st March, 2018

pickab00 started a new conversation Integrity Constraint Violation: 1048 Column 'notifiable_id' Cannot Be Null • 3 months ago

Ok the issue is that i am trying to pass multiple notifiable_id to the notification table. Here is my current code:

$user = new User;
$user->notify(new RoomStatusRoomboy($notifyroomnumber, $created_at_stamp));

What i was trying to achieve was, to notify multiple users and not only one user. Previously i had this code:

Auth::guard('web')->user()->notify(new RoomStatusRoomboy($notifyroomnumber, $created_at_stamp));

This code only notified a single user. I want to be able to send the notification to all the available users. And with Auth::guard('web')->user()->notify(new RoomStatusRoomboy($notifyroomnumber, $created_at_stamp)); code, the notifiable_id is 1

Many thanks

28th February, 2018

pickab00 left a reply on Call To A Member Function UnreadNotification() On Null • 3 months ago

@nchristiansen Not sure if you follow the issue. The problem is when the admin is logged out. this code {{\Illuminate\Support\Facades\Auth::guard('admin')->user()->unreadNotifications()->count()}}is in one of my web guards view blade file. And it is calling for guard admin. And admin is logged out so it will give a on null error. Is there any alternative to my current code. in my database, the notifyabe_type is App\Admin. I want to fetch those but i am using admin guard and admin is logged out. That is the problem

pickab00 started a new conversation Call To A Member Function UnreadNotification() On Null • 3 months ago

So here is the thing. This has been bugging me for a while and i cant seem to get a solid fix on this. I have 2 guards. one is admin and the other web. So i have multi auth setup.

I have setup the notification like so:

-Admin:

Auth::guard('admin')->user()->notify(new RoomStatusRoomboy($notifyroomnumber, $created_at_stamp));

-User (normal auth):

\auth()->guard('web')->user()->notify(new RoomStatusReception($notifyroomnumber, $created_at_stamp));

I am getting the results fine. But i have this code in my normal auths blade. this code is inside of one of the blade files which i use to display notifications:

{{\Illuminate\Support\Facades\Auth::guard('admin')->user()->unreadNotifications()->count()}}

I am counting the number of notifications for admin auth inside of a web auth. so it will look for App\Admin. But the thing is i am getting call to a member function unreadNotification() on null error. and i think that it is because of the auth. I am trying to view this with the admin logged out. When i log in as admin on another tab and retry, it works. But with admin logged out, it does not work.

Please note that {{\Illuminate\Support\Facades\Auth::guard('admin')->user()->unreadNotifications()->count()}} is inside of a view of normal auth and not admin. This is inside of a web logged auth.

Hope i am making sense here. Thanks in advance.

pickab00 started a new conversation Call To A Member Function Notify() On Null • 3 months ago

I am having the weirdest problem. I have a multi auth with multi guard setup. And i have notifications on both of them. Here is how my save methods notify looks like on my controller:

    Auth::guard('admin')->user()->notify(new RoomStatusReception($notifyroomnumber, $created_at_stamp));

And its returning Call to a member function notify() on null

I am honestly confused of why this is occurring. I have another controller with the same line of code which works perfectly. I also have the notifiable trait on my Admin model.

Thanks

pickab00 started a new conversation How To Auto Refresh A Div On X Seconds • 3 months ago

This maybe a broad question but here is the thing. I am using laravel and i have a database notification which displays the amount of unread badges (bootstrap badges) and a list of read and unread notifications. I want to be able to refresh only that div every 5 seconds or so.

Here is the code for database notification on my blade so far (admin-master.blade.php):

<li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="lnr lnr-bullhorn"></i> <span class="badge badge-light">{{\Illuminate\Support\Facades\Auth::guard('admin')->user()->unreadNotifications()->count()}}</span><i class="icon-submenu lnr lnr-chevron-down"></i></a>
                    <ul class="dropdown-menu">
                        @foreach(\Illuminate\Support\Facades\Auth::guard('admin')->user()->unreadNotifications as $notifications)
                        <li><a class="unreadNotifications" href="{{route('receptionist.markasread', $notifications->id)}}">{{$notifications->data['data']}}
</a></li>
                        @endforeach
                            @foreach(\Illuminate\Support\Facades\Auth::guard('admin')->user()->readNotifications()->take(4)->get() as $notifications)
                                <li><a class="readNotifications" href="/admin/roomstatus">{{$notifications->data['data']}}</a></li>
                            @endforeach
                    </ul>
     </li>

So my question is, how can i use JS with this laravel to refresh the whole div. I want to be able to refresh both the badges and the actual notifications. I have seen some posts on stack overflow suggesting to use AJAX to "load" an html. I am not sure how i could achieve that with laravel.

Thanks

26th February, 2018

pickab00 left a reply on Laravel Blog User Post • 3 months ago

@Hsmith1947 Here is where you went wrong

If you want to display your users name which the post belongs to, you should use laravels "with()" method. Here is an example.

public function show($id)
    {
    $user = User::findOrFail($id);
        return view('user.profile', compact('user'));
    }

So in your 'user.profile' view file you should do:

@foreach($user as $userProfile)
    
    {{ $userProfile->name }}
    {{ $userProfile->avatar }}

@endforeach 

If you want to display the users information on your master blade file then you could simply use this:

{{\Illuminate\Support\Facades\Auth::user()->name}}
{{\Illuminate\Support\Facades\Auth::user()->avatar}}

This way, you don't need to pass in a variable from a controller to your view. You could just simply display the information of the authenticated user.

Also for another question of yours, use 'with()' method. Here is an example:

public function show($id){

    //this is the show post method
    //here the with('user') is the user function on your user model
    //All this is assuming you have a user_id field in your post table
    //NOTE: notice that i haven't used findOrFail? Its because findOrFail is a static method. There are ways you can inject it but lets not worry about that now ;) Only 'find' will work with 'with()' in this case. Sorry for the long comments xD

    $post = Post::with('user')->find($id);

    return view('post.single.page', compact('post'));

}

Now on your single page blade view file:

$post->user->name

If you want to loop through all the posts and display the written posts instead of showing each post, you could do this:

public function index($id){

    //Lets assume you have a table in your index view which you want to display all posts in to with the user name instead of user_id. with 'with()'
    //All this is assuming you have a user_id field in your post table

    $post = Post::with('user')->get();

    return view('post.index.page', compact('post'));

}

In your blade file where your table is:

    @foreach($post as $postTable)

    <td>{{ postTable->user->name }}</td>
    <td>{{ postTable->title}}</td>
    <td>{{ postTable->content}}</td>

@endforeach

PHEW! I think (as per my understanding of your question(s) ) that's how you are suppose to do it. Hope this helps. And for anyone who needs help in such a situation.

Cheers!

pickab00 started a new conversation Notification Not Working On Multiple Guards • 3 months ago

I have 2 guards. One 'user' and the other 'admin'.

Here is my code in blade file:

<span class="badge badge-light">{{count(auth()->guard('admin')->user()->unreadNotifications())}}</span>

But i am only getting '1' as a result. I have 6 records in my table. Also my forech loop is not working either with guard. Here is the code:

<ul class="dropdown-menu">
                            @foreach(auth()->guard('admin')->user()->notifications() as $notifications)
                           <li>{{$notifications->type}}</li>
                        @endforeach
</ul>

Thanks a bunch

pickab00 left a reply on Pass Variable To Laravel Notification • 3 months ago

Thanks. All the answers above works.

pickab00 started a new conversation Pass Variable To Laravel Notification • 3 months ago

I have my controller setup and when ever the user stores some data, the notification is stored in the database.

Here is the line from my controller:

$notifyroomnumber = $request->get('roomnumber');

\auth()->user()->notify(new RoomStatusReception());

I want to pass the $notifyroomnumber variable to my notification class.

Here is my notification class ('RoomStatusReception'):

public function toDatabase($notifiable)
    {

        return [

        'data'=>'room number xxx cleaned'

    ];
}

I want to send the $notifyroomnumber to that array.

Thanks.

25th February, 2018

pickab00 left a reply on SSL Certificate On Laravel Development • 3 months ago

Yeah i just came to know that laravel uses php's inbuild server which is the native HTTP and does not support HTTPS. For anyone who is wondering, artisan serve command SSL is not possible :)

pickab00 started a new conversation SSL Certificate On Laravel Development • 4 months ago

I have an application which i am using 'php artisan serve' command to run it on my mobile. I want to test it on my mobile but i have an API which requires HTTPS. So how can i configure this? I want to test this before I put this live.

Here is how my artisan command looks like:

php artisan serve --host=192.168.1.18 --port=80

The IP is my local machines IP Address which i am accessing from my mobile.

Thanks.

18th February, 2018

pickab00 left a reply on Maatwebsite/Laravel-Excel How To Manipulate A Row If The Result Is Equal To A Specific Value • 4 months ago

@Corban I solved the issue. the problem was with my relation. Not the code. Your proposed solution works for me. But i must confess, i need to update my question. I accidentally wrote, "row" instead of column. i wanted the color to change only on that specific column.

eg: if the id 1's verified is equal to 1 then change only that specific columns color. Like id 1's only verified column to be green. Hope this makes sense. There is no mention of how to manipulate specific column on the docs.

Thanks

pickab00 left a reply on Maatwebsite/Laravel-Excel How To Manipulate A Row If The Result Is Equal To A Specific Value • 4 months ago

@Corban haha. We'll get back to the color issue way later xD Anyways thanks. I will leave a post as soon as i get some time to test it.

pickab00 left a reply on Maatwebsite/Laravel-Excel How To Manipulate A Row If The Result Is Equal To A Specific Value • 4 months ago

@Corban I don't think it is taking time. I am away from my pc at the moment. This error comes instantly. There is no delay or processing going on whatsoever

pickab00 left a reply on Maatwebsite/Laravel-Excel How To Manipulate A Row If The Result Is Equal To A Specific Value • 4 months ago

@Corban I cant seem to figure out why but i am getting the invalid response error:

The webpage at http://test.com/admin/export might be temporarily down or it may have moved permanently to a new web address. ERR_INVALID_RESPONSE

Here is the code updated:

$clean = Clean::with('users')->get();

    Excel::create('Report', function($excel) use($clean){
        $excel->sheet('Sheet 1', function($sheet) use($clean){
            $sheet->row(1, array('Room Attendant Name', 'Room Number', 'Verified'));

            $i = 2;

            foreach ($clean as $cleans) {

                if($cleans->verified == 1){
                    $sheet->row($i, function($color) {
                        $color->setBackground('#008000');
                    });
  }

                $sheet->row($i, array($cleans->users->name, $cleans->roomnumber, $cleans->verified));
                $i++;
            }

            $sheet->setAutoFilter();
        });
    })->download('xlsx');

There isn't any stacktrace either on laravels log

pickab00 started a new conversation Maatwebsite/Laravel-Excel How To Manipulate A Row If The Result Is Equal To A Specific Value • 4 months ago

I am using Maatwebsite/Laravel-Excel Package to export some data in my database. Here is where i have gone so far.

What i am doing here is, i am taking the "user_id", "roomnumber" & "verified" column from my "cleans table. I have joined the "users" table so that i get my user name instead of the "user_id". Its a simple query.

Whats confusing me though is, how can i manipulate the "verified" row (its of course an array) if the result is equal to "1". I want to be able to change the background color of the row if the value is 1.

Here is a line from the docs which is related to manipulating a specific row.

$sheet->setStyle(array( 'font' => array( 'name' => 'Calibri', 'size' => 12, 'bold' => true ) )); I am not sure how to continue from there. How should i state the if else statement.

Here is the code i have so far:

$clean = Clean::select('users.name', 'cleans.roomnumber', 'cleans.verified')->join('users','users.id','=','cleans.user_id')->get();

Excel::create('Report', function($excel) use($clean) {
    $excel->sheet('Sheet 1', function($sheet) use($clean) {

        $sheet->fromArray(array(
            array('Room Attendant Name', 'Room Number', 'Verified')
        ));


        $sheet->fromArray($clean, null, 'A1', false, false);
    });
})->export('xls');

Hope this information was enough.

Thanks in advance.

16th February, 2018

pickab00 started a new conversation Maatwebsite/Laravel-Excel Package Manipulate Before Export • 4 months ago

Hi,

I couldn't find any helpful links in the docs and i was wondering if there is anyone who is experienced in using this package?

Basically i want to manipulate the data before its exported. In the sense, i want my "user_id" to change to "User Name" and also display the related users name based on the user_id. Also if "verified" is equal to 1 then the excel will have "Yes" instead of number 1.

Here is what i have so far to export all data in my Table:

public function excelExport()
{
    $export = Clean::all();
    Excel::create('Export', function ($excel) use ($export) {
        $excel->sheet('Sheet 1', function ($sheet) use ($export) {
            $sheet->fromArray($export);
        });
    })->export('xlsx');

    return redirect()->back();
    }

Thanks in advance

15th February, 2018

pickab00 left a reply on Include A Foreach Looped Variable From Controller To Blade • 4 months ago

@Dunsti I now see what is happening. Thanks a bunch :D

You learn something new from the best everyday XD

pickab00 left a reply on Include A Foreach Looped Variable From Controller To Blade • 4 months ago

@Dunsti Any other method? Fits off, what would be the $cleanObj? I used the same code as the original question in the model and it still results on one single result being looped.

pickab00 started a new conversation Include A Foreach Looped Variable From Controller To Blade • 4 months ago

This is an interesting question which i have been trying to tie my head around.

I have a foreach loop in my controller which loops through my time stamps to find the time difference from two arrays. A start time and an end time. I amusing carbon.

Now that loop returns the results with no issues. The problem is that i already have a loop inside of blade which takes rows from my db and outputs the data. My question is, how can i send the looped data's result in my controller to the views foreach.

Here is my blades for each:

@foreach($clean as $cleans)
                <tr>

                    <td>{{$cleans->roomnumber}}</td>
                    <td>{{$cleans->users->name}}</td>
                    <td>{{$diff **Here i want to display the loop from controller but only one result comes because its not being looped**}}</td>
                    @if($cleans->verified == 1)<td class="verified">Yes</td>@else()<td     class="notverified">No</td>@endif
                    @if($cleans->img1 || $cleans->img1 || $cleans->img1 == !null)<td     class="verified">Yes</td>@else()<td class="notverified">No Issues</td>@endif
                    <td>{{$cleans->created_at->diffForHumans()}}</td>
                    <td><a href="{{route('starlord.show', $cleans->id)}}"><i class="lnr lnr-eye">    </i></a></td>
                </tr>

            @endforeach

Here is my Controller (Everything i have written so far):

$cleanCollection = Clean::get(['starttime','endtime']);
    foreach($cleanCollection as $cleanObj){
        $startTime = Carbon::parse($cleanObj->starttime);
        $diff = $cleanObj->endtime->diffInMinutes($startTime);
    }

    $clean = Clean::with('users')->orderBy('verified', 'asc')->latest()->paginate(5);

    return view('admin/view', compact('clean', 'diff'));

In basic i want the $diff variable to loop with the $cleans foreach. Currently $diff is returning only one result and $cleans repeats it inside its loop.

Many Thanks

14th February, 2018

pickab00 left a reply on AJAX GET Reqest • 4 months ago

@daniyum21 Its giving me 500 internal server error. I console logged it.

Here is the error:

GET http://unima.com/admin/search 500 (Internal Server Error)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
n.(anonymous function) @ jquery.min.js:4
(anonymous) @ view:233
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3

"(anonymous) @ view:233" is this line:

$.get("/admin/search", function(data, status){

I have also updated my question by adding my routes

13th February, 2018

pickab00 left a reply on AJAX GET Reqest • 4 months ago

@ikarus like i said, i am new to ajax. Right now with the above code, when i click the search button it navigates to the url given and displays the results

pickab00 left a reply on SQLSTATE[42S02]: Base Table Or View Not Found: 1146 Table 'forge.decisions' Doesn't Exist • 4 months ago

@tykus This maybe a bit random but can you explain why we need to put this bit in to boot

public function boot()
{
Schema::defaultStringLength(191);
if (Schema::hasTable('decisions')) {
    $badge = Decision::where('done',false)->count();
    View::share('badge',$badge);
}
}

Why the boot. what does boot do? I partially know what boot does. All i know at this point is that laravel boots all the service providers before and calls everything inside of boot later. Am i wrong?

Care to spread the knowledge to a brother who is keen to seek? ;)

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.