michalis

michalis

Member Since 3 Years Ago

Experience Points 12,050
Experience Level 3

2,950 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 142
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

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

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

17 May
1 week ago

michalis left a reply on How Do I Create A Join With The Query Builder When I Have A Pivot Table?

@GRENADECX - thank you sir, it worked

although I dont understand why

how does the query know that I want it to check the pivot table?

I hope its not a stupid question

16 May
1 week ago

michalis started a new conversation How Do I Create A Join With The Query Builder When I Have A Pivot Table?

I have a campaigns table, an items table, and a campaign_item pivot

I would like to get all the items that belong to 1 campaign but not sure how to do it given the pivot table

is it possible?

michalis left a reply on Using The Query Builder For A Many To Many Relationship?

basically I had a belongsTo relationship and this was my code

        $files = File::where('campaign_id', $id);


        if ($month = request('month')) {
            $files->whereMonth('created_at', Carbon::parse($month)->month);
        }

        if ($year = request('year')) {
            $files->whereYear('created_at', $year);
        }

        $files = $files->orderBy('created_at', 'desc')->paginate(10);

this worked

but I now changed to a belongsToMany relationship with a pivot table and not sure how to implement it on the front end

because of the if statements, I think what you are suggesting wont work

michalis left a reply on Using The Query Builder For A Many To Many Relationship?

@BOBBYBOUWMANN - I need to get all items that belong to one campaign, and chain other queries on them like whereMonth() and orderBy()

how would a join look like in laravel?

michalis started a new conversation Using The Query Builder For A Many To Many Relationship?

I have a campaigns table and and an items table, and the pivot table is campaign_item

is it possible to use the query builder to get all items that belong to a campaign?

I ask because I need to chain some queries on it, but in the docs it only shows how to get the relationship through eloquent

I search online and there are a few threads about the subject but I'm still not sure how to go about it

15 May
1 week ago

michalis started a new conversation How To Paginate And Sort Results?

I have an issue, If I use sortByDesc, the then $files->links() wont work in blade

        $files = File::where('campaign_id', $id);

        if ($month = request('month')) {
            $files->whereMonth('created_at', Carbon::parse($month)->month);
        }

        if ($year = request('year')) {
            $files->whereYear('created_at', $year);
        }

        $files = $files->paginate(2)->sortByDesc('created_at');

when I go to the view I get

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

if I do the opposite

 $files = $files->sortByDesc('created_at')->paginate(2);

I get

Call to undefined method Illuminate\Database\Eloquent\Builder::sortByDesc()

is it possible to paginate as well as sort the items?

michalis left a reply on How To Add Pagination To This Code

@ROBSTAR - I have, it did not mention that get() and paginate() do the same thing, or maybe I didnt understand

michalis left a reply on How To Add Pagination To This Code

@ANDREICH1980 - if i do this

$files = $files->paginate(15)->get()->sortByDesc('created_at');

I get this error

Too few arguments to function Illuminate\Support\Collection::get(), 0 passed in and at least 1 expected

michalis started a new conversation How To Add Pagination To This Code

    $files = File::where('campaign_id', $id);

        if ($month = request('month')) {
            $files->whereMonth('created_at', Carbon::parse($month)->month);
        }

        if ($year = request('year')) {
            $files->whereYear('created_at', $year);
        }

        $files = $files->get()->sortByDesc('created_at');

I tried adding it on the first line but get

Too few arguments to function Illuminate\Support\Collection::get(), 0 passed, at least 1 expected

I tried adding it on the last line and get

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

michalis left a reply on How To Use Storage::download()

i ended up using response()->download(file)

14 May
1 week ago

michalis left a reply on 'Method Does Not Exist' When Using WhereMonth()

thank you for taking the time guys, the problem was that 'files' was not a query

so instead of getting files through its relationship, I had to get it through a query so I could append the whereMonth and whereYear queries

        $files = File::where('campaign_id', $id);

        if ($month = request('month')) {
            $files->whereMonth('created_at', Carbon::parse($month)->month);
        }

        if ($year = request('year')) {
            $files->whereYear('created_at', $year);
        }

        $files = $files->get();
13 May
1 week ago

michalis started a new conversation 'Method Does Not Exist' When Using WhereMonth()

I am following along from jeffery's tutorial on how to create an archive but trying to adapt it to my own neads

https://laracasts.com/series/laravel-from-scratch-2017/episodes/20

here is my code

public function index($id)
    {
        $campaign = Campaign::find($id);
        $files = $campaign->files->sortByDesc('created_at');

        if ($month = request('month')) {
            $files->whereMonth('created_at', Carbon::parse($month)->month);
        }

        if ($year = request('year')) {
            $files->whereYear('created_at', $year);
        }

        $archives = File::selectRaw('year(created_at) year, monthname(created_at) month, count(*) published')
            ->where('campaign_id', $id)
            ->groupBy('year', 'month')
            ->OrderByRaw('min(created_at) desc')
            ->get();

        return view('files', ['files' => $files, 'archives' => $archives]);
    }

on the front end I get

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

I think i understand the issue but not how to overcome it, do I need to get files with a query instead of through a relationship?

michalis started a new conversation ToArray(), WhereMonth(), WhereYear() Deprecated?

I need to create something like what jeferrey does in this video

https://laracasts.com/series/laravel-from-scratch-2017/episodes/20

but some functions dont seem to be working, the series is from laravel 5.4

are there alternatives to the above methods?

michalis left a reply on Alternative Ways To Download A File ? (using Storage::download)

I found response()->download(file)

which seems to work, is that the best way to do it?

michalis started a new conversation Alternative Ways To Download A File ? (using Storage::download)

any alternative ways to using Storage::download?

I keep getting a file not found exception with this method, even though the file is there

michalis left a reply on How To Use Storage::download()

@JAY_CHAUHAN - ``` return Storage::download($link);


in this code, link is 

C:/Users/com2go/Desktop/code/social_manager/public/storage/files/May2019/4ZLCxnK7Py2J1NpQTlS9.cs


and the path of the file on the hard drive is 

C:\Users\com2go\Desktop\code\social_manager\storage\app\public\files\May2019\4ZLCxnK7Py2J1NpQTlS9.css

michalis left a reply on How To Use Storage::download()

@JAY_CHAUHAN - clearing the cache didnt work, as for the other one i did this

return Storage::download('storage', $link[0]->download_link);

but i get

The filename and the fallback cannot contain the "/" and "\" characters.

michalis started a new conversation How To Use Storage::download()

this is my method

    public function download($id)
    {
        $file = File::find($id);
        $link = json_decode($file->link);

        return Storage::download('storage/' . $link[0]->download_link);
    }   

but it wont download the file, I get a file not found exeption

League \ Flysystem \ FileNotFoundException
File not found at path: storage/files/May2019/caAsV09m4I5FZdOmALIZ.png

the path i correct though, not sure why its not working

when I do it as a link on the front end it works, but doing it from a method in the backend does not work for some reason

am I using the function correctly?

09 May
2 weeks ago

michalis started a new conversation How To Create A Calendar To Show Archived Posts?

e.g on the sidebar there would be a list of years and months and when you click you see the posts only for that month

I guess the biggest issue would be how to create that calendar dynamically, to only show years and months that actually have posts

Im stumped as to how to go about it, is there a tutorial out there for something similar?

would I need to change the structure of my database? eg have a month column on my posts table?

I would appreciate any help

08 May
2 weeks ago

michalis started a new conversation Is This A Problem With Laravel Or With Voyager?

I tried this twice and get the same issue each time

using laravel 5.8/php7.3 /voyager1.2

I install laravel, install voyager, create my first database table ok, then on creating the second table i get an error, then I cant access the databases route anymore. this happened twice and i get this error when trying to access admin/database

Route [voyager.assets.index] not defined. (View: C:\Users\com2go\Desktop\code\socialmanager\vendor\tcg\voyager\resources\views\tools\database\index.blade.php)
* @return string
     *
     * @throws \InvalidArgumentException
     */
    public function route($name, $parameters = [], $absolute = true)
    {
        if (! is_null($route = $this->routes->getByName($name))) {
            return $this->toRoute($route, $parameters, $absolute);
        }
 
        throw new InvalidArgumentException("Route [{$name}] not defined.");
    }
 
    /**
     * Get the URL for a given route instance.
     *
     * @param  \Illuminate\Routing\Route  $route
     * @param  mixed  $parameters
     * @param  bool   $absolute
     * @return string
     *
     * @throws \Illuminate\Routing\Exceptions\UrlGenerationException
     */
    protected function toRoute($route, $parameters, $absolute)
    {
        return $this->routeUrl()->to(
07 May
2 weeks ago

michalis started a new conversation I Would Like To Register Users Manually, Any Relevant Videos/guides?

does anyone know the solution to this or is there a video to watch?

I would also like to disable the /register route route but not sure how since it does not appear in web.php, would appreciate you pointing me in the right direction

michalis started a new conversation Should I Use Javascript To Update Database Or Do A Form Button?

I have a download link and I track how many times its downloaded, the number is displayed next to the download link

when the link is clicked, should I use javascript/ajax to change it in the database and refresh the view?

or should I do something like a form button, which when clicked sends a patch request, then the method updates the db, calls the function to start the file download and redirects to the previous page?

which would be the simpler and more elegant way? is there a way im not thinking of?

michalis left a reply on Request()->file()->store() Does Not Save In Public Directory

@EDOC - @edoc

I apologize if i'm being persistent, but I cant find anything in the docs about setting the filesystem driver, could you possibly provide a link? trying to understand whats going on

06 May
2 weeks ago

michalis left a reply on Request()->file()->store() Does Not Save In Public Directory

@EDOC - this wasnt in the documentation either I think, it just an overwhelming feeling trying to learn laravel when you cant trust the docs

michalis left a reply on Request()->file()->store() Does Not Save In Public Directory

@EDOC - ok this worked and I dont understand why it worked, did i not read the documentation properly?

michalis left a reply on Request()->file()->store() Does Not Save In Public Directory

@EDOC - filesystem config looks the same as yous, i did not mess with it

this is my code

$path = request()->file('asset')->store('assets');

this should save in storage/app/public/assets

but it saves in storage/app/assets

for the life of me I dont know why

michalis left a reply on Request()->file()->store() Does Not Save In Public Directory

@MUNAZZIL - ``` public function store($id) { // dd(request()->all());

    $path = request()->file('asset')->store('public');

    $asset = new Asset();
    $asset->project_id = $id;
    $asset->title = request('title');
    $asset->file = $path;
    $asset->downloaded = 0;
    $asset->save();

    return back();
}
as you see i have to tell laravel to store in public folder or else it doesnt

        @foreach ($project->assets as $asset)
            <li>{{ $asset->title }}, <a href="{{ asset($asset->file) }}">download</a>, Downloaded {{ $asset->downloaded }} time(s)</li>
        @endforeach

and the url i get is this, which is wrong

http://127.0.0.1:8000/public/kMpIp6i0xeUMLfbweoI2nBjQ40sOX18bWswW66Hy.jpeg

michalis started a new conversation Request()->file()->store() Does Not Save In Public Directory

it saves int the storage/app directory, so when I create a symlink things dont work, what am I missing?

michalis started a new conversation Tutorial On File Storage?

hello guys, is there a video on laracasts about this?

I need to create something that allows the user to upload a file

I found one video but its from 2013 so i'm guessing its outdated

25 Apr
4 weeks ago

michalis left a reply on Should I Use Voyager With This Project?

@bobbybouwmann

to be honest those are not questions I know the answers to. I will assume that all projects grow with time, but to what extend and in what direction I am not sure

I guess maybe a better question would be, given the functionality I mentioned, would voyager make it easier to complete the project, or would it add another thing I need to learn which will just slow me down, I will be learning laravel, and doing the project at the same time

michalis started a new conversation Should I Use Voyager With This Project?

guys I would really love the opinion of seasoned developers on this

I have to create a site where there will be regular users and admins

admins will be able to create new users and new projects, and add files (psd, doc) associated with specific projects

the regular user will only be able to see the projects that belong to them, and download the associated files, no power to add, edit or delete

is this a project that would benefit from using voyager? or would it be a hindrance?

thanks in advance for the help

michalis left a reply on Best Way To Tackle This App? Ideas Welcome

@triumfator

I will definitely check it out, sounds like what I need, I really appreciate it, Im afraid to use it at the moment as I am still trying to learn laravel, would it complicate things for me too much? maybe I should learn laravel well before trying to add complexity?

michalis left a reply on Findorfail, @csrf And @method Dont Seem To Work

@ftiersch

I apologize, I do not understand, Im a novice. You are saying the handling is wrong, is it something that I did, something I can fix, or are you saying the difference in handling is due to the difference in the laravel versions

24 Apr
1 month ago

michalis left a reply on Which Series Are Still Applicable For Laravel 5.4

@SERGIU17 - oh thanks, wondering which other series are relevant to v5.4

michalis started a new conversation Which Series Are Still Applicable For Laravel 5.4

I found the laravel 5.4 from scratch through google, cant seem to find it on the site though

are there other series applicable to laravel 5.4?

unfortunately that is the version I have to use

most series dont seem to mention what version they use and as I have realised today, there are sizable changes between versions of laravel

michalis left a reply on Findorfail, @csrf And @method Dont Seem To Work

@edoc

thank you :)

is it the same with findOrFail? from my understand its not but still dont get why it doesnt work

michalis started a new conversation Findorfail, @csrf And @method Dont Seem To Work

been following along with the laravel from scratch series

findorfail leads to a NotFoundHttpException instead of a 404

and the blade helpers @csrf and @method dont work either they just appear on the page as text, when using the curly braces syntax they do work

im on v5.4, could that be the problem?

michalis left a reply on Prerequisites Before Learning Laravel?

@jlrdw

thank you for the resources, they look good, especially the one for security, but I dont think I have the knowledge required to follow whats going on, maybe after i learn a little bit of laravel and php. are those materials for more advanced users or is it just me?

michalis left a reply on Best Way To Tackle This App? Ideas Welcome

@digiproduct

I will, just going through laravel from scratch a second time so that I can get a better understanding before going in deeper

23 Apr
1 month ago

michalis left a reply on Best Way To Tackle This App? Ideas Welcome

@braunson

wow thanks for taking the time to write such a long and descriptive post, it makes things a lot more clear

michalis left a reply on When I Install Laravel I Get V5.4

@devfrey many thanks, I feel like a complete noob for not even knowing what php version I installed

michalis left a reply on Voyager Vs Nova

@safemood many thanks, ill keep this in mind and watch the video

michalis left a reply on Prerequisites Before Learning Laravel?

@nash @martinbean

thank you both for your response, I will start watching some laracasts php videos

are there areas laracasts does not cover that would benefit me in my attempt to better understand laravel?

michalis started a new conversation Best Way To Tackle This App? Ideas Welcome

please note that I am fairly amateur, so you might have to dumb it down for me

I need to create an app that will have clients and admins, admins will be able to view projects and edit/create them. clients will only be able to view projects assigned to them

is there a best way to tackle this?

e.g. do I have 1 users table and one column that indicates this is an admin or client? then some middleware that checks if its an admin or a client with authorisation?

or would i need an admin table separate from a users table

michalis left a reply on Voyager Vs Nova

@safemood I appreciate you taking the time to explain things to me

I am a novice basically so some concepts are over my head

does the fact that voyager saves to the database, mean that I have to migrate the database when i deploy my app? and does this mean that I dont need to do it with nova?

michalis left a reply on When I Install Laravel I Get V5.4

@devfrey you were right, php is v 5.6 which i do not understand since i installed everything now, would have assumed i would have gotten a more recent version of php

michalis started a new conversation When I Install Laravel I Get V5.4

is that normal? I followed official laravel documentation. shouldnt i have got v 5.8?

i;ve only done a few hours work on it

is it better to upgrade, or to make a new fresh 5.8 installation? anyone know how to force the installer to install the latest version?

michalis started a new conversation Prerequisites Before Learning Laravel?

having a hard time following the jeffrey in the videos

is there some prerequisite level of knowledge before watching the videos? like how advanced you have to be in php?

I have more trouble with laravel concepts like service containers for example

should i first read about software architecture or something?

even laravel from scratch seems to be for people that have used laravel before or i'm just daft