1

First please be gentle i am a beginner and im only coding for practise.

I try to pass an instance to the model but i always get this error

Argument 1 passed to Store::__construct() must be an instance of Illuminate\Filesystem\Filesystem, none given

my model

<?php

use Illuminate\Filesystem\Filesystem as File;

class Store extends Eloquent
{
    public $timestamps = false;

    public function __construct(File $file)
    {
        $this->file = $file;
    }

}

Could please somebody tell me what i am doing wrong?

thank you

EDIT

I just used simply like this in my Controller

public function index()
    {
        $store = new Store;
        return View::make('store', $store);
    }
1
  • new Store; you're not passing a File instance, and the constructor expects one Commented Nov 8, 2013 at 14:03

1 Answer 1

3

The File class is one of Laravels Facades, which means you do not need to pass it into your models construct.

You can access it from anywhere in Laravel using File::someMethod(). If you use namespaces then you have to access via the root namespace \File::someMethod().

Within your store view you can access the File facade directly with the aforementioned method.

Take a look at the documentation on the file system here http://laravel.com/api/class-Illuminate.Filesystem.Filesystem.html

So you can use File::copy() without having to instantiate a class as it is called from a static method.

Sign up to request clarification or add additional context in comments.

4 Comments

you misunderstood, i am not needing the input file, i am needing the FileSystem for creading folders and manipulating files, such as appending content to it: laravel.com/api/class-Illuminate.Filesystem.Filesystem.html
maybe it should be better if i would call it in the controller instead of the model
Yeah I got the link wrong that is what I was referring to, File is basically an alias to this class.
No problem, you should take a look at the core Laravel files in vendor/laravel/framework/src/Illuminate. You will get a better understanding of how the framework operates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.