isamirsalehi

isamirsalehi

Member Since 8 Months Ago

Experience Points
860
Total
Experience

4,140 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

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

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
860 XP
Oct
13
2 weeks ago
Activity icon

Started a new Conversation (temporarySignedRoute) Route [download.project.file] Not Defined.

Hey there

when i use temporarySignedRoute in route/web.php it gives below error

Route [download.project.file] not defined.

but I've already made this route

Route::get('/download/{project}', '[email protected]')->name('download.project.file')->middleware('signed');

Thanks for helping me in advance

Sep
30
1 month ago
Activity icon

Started a new Conversation Composer Dump-autoload Generating Optimized Autoload Files > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php Artisan Package:discover --ansi Null Script @php Artisan Package:discover --ansi Handling The Post-autoload-dump Event Returned Wit

Hi there.

Recently whenever I wanna update my composer or dump-autoload it, it gives me the blow error and I also can't the logged in user


$ composer dump-autoload
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
null
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1


Sep
28
1 month ago
Activity icon

Replied to How Can I Run Some Code In All Over The Application

I'm working on a project that some guy can define some Projects and some designer can send their plans to the Projects that they registered to.

I wanna check if a project doesn't get any plans close to the deadline then send a notification to the project's owner that you can extend your deadline.

So i think it's better if i check the deadline and no plan sent in some where that can run all over the application. @automica

Activity icon

Started a new Conversation How Can I Run Some Code In All Over The Application

Hi guys. I wanna write some code to run all over my application, something needs to be checked by some code.

Where is a good place to write those code? or what is the best way to do that?

Sep
26
1 month ago
Activity icon

Replied to My Custom Login Class Hes Been Changed Automatically

I got it. I've modified the AuthenticatesUsers trait

Activity icon

Replied to My Custom Login Class Hes Been Changed Automatically

I've just edited the original login class

Activity icon

Replied to My Custom Login Class Hes Been Changed Automatically

yes i use them in my project. but merge the new versions. and I've updated composer for several times, is that the problem?

Activity icon

Started a new Conversation My Custom Login Class Hes Been Changed Automatically

Hi guys. I've edited the original login class for several times to customize it but it has been changed for no reason automatically to the first day it was. What's problem?

Sep
24
1 month ago
Activity icon

Started a new Conversation How To Set Suitable Name For Routes

Hi guys. Maybe it happened to you before that you were thinking about what name i should set for the route that you've defined. My question is how can i set a suitable name for my route? Is there any rule for it? I just wanna have meaningful routes name

Sep
22
1 month ago
Activity icon

Replied to How Can I Download Zip Files In Laravel?

thank you so much

Activity icon

Replied to How Can I Download Zip Files In Laravel?

ok.

I called the method just like this to download the zip file:

Route::get('/download', function(){
    $a = Attachment::where('project_id', 2)->get();
    FileController::downloadZip($a);
});

When i call the downloadZip method, it compress all the files related to the project and give me a zip file as result :

    public static function downloadZip($files)
    {

        $folderName = explode('/', $files[0]->file_path);
   
        $directoryPath = public_path($folderName[0] . '\' . $folderName[1] . '\' . $folderName[2]);

        $fileName =  $directoryPath . '\' . "$folderName[2].zip";

        if(!file_exists($fileName)){
            $zip = Zip::create($fileName);

            $zip->add($directoryPath, true);
    
            static::download($fileName);

            $zip->close();
        }

        return static::download($fileName);
    }

as you can see i call the Download method inside DownloadZip method, like above. the download method is:

    public static function download($file)
    {
        if(is_string($file))
        {
            return FacadesResponse::download($file, substr($file, strrpos($file, '\') + 1), array('Content-Type: application/octet-stream','Content-Length: '. filesize($file)))->deleteFileAfterSend(true);
        }
        
        $filePath = public_path($file->file_path);

        return FacadesResponse::download($filePath);
    }

in the end when i call the /download route it does not download the zipped file. Could you tell me what should i do for it?

Activity icon

Replied to How Can I Download Zip Files In Laravel?

thanks for your reply but unfortunately it does not work too

Activity icon

Replied to How Can I Download Zip Files In Laravel?

there isn't any error, it just doesn't download the zip file

Activity icon

Started a new Conversation How Can I Download Zip Files In Laravel?

Hi guys

I wanna download zip file and i've implemented two function, -downloadZip- for creating zip files and -download- for downloading files.

All i said are below but Download method does not work, What should i do?

public static function download($file)
    {
        if(is_string($file))
        {
            return FacadesResponse::download($file, substr($file, strrpos($file, '\') + 1), array('Content-Type: application/octet-stream','Content-Length: '. filesize($file)))->deleteFileAfterSend(true);
        }
        
        $filePath = public_path($file->file_path);

        return FacadesResponse::download($filePath);
    }


    public static function downloadZip($files)
    {

        $folderName = explode('/', $files[0]->file_path);
   
        $directoryPath = public_path($folderName[0] . '\' . $folderName[1] . '\' . $folderName[2]);

        $fileName =  $directoryPath . '\' . "$folderName[2].zip";

        if(!file_exists($fileName)){
            $zip = Zip::create($fileName);

            $zip->add($directoryPath, true);
    
            static::download($fileName);

            $zip->close();
        }

        return static::download($fileName);
    }

Sep
14
1 month ago
Activity icon

Replied to Mysql Database Views In Laravel

Thank you for replying. In createView and dropView you used << SQL: syntax but mine doesn't work. What should i do? Should i install a package for it?

Activity icon

Started a new Conversation Mysql Database Views In Laravel

Hi guys.

I need to create a view in my database (Mysql) but i'm thinking about how can i access and control it in my Laravel application. What can i do for it? How can i create a migration and model for it?

Sep
08
1 month ago
Activity icon

Started a new Conversation Validation Pdf's Number Of Pages

Hi everyone

There is form in my project that users upload their pdf files. I wanna validate the number of pages of uploaded pdf file. So is there any package for it or Laravel has any validation for this case?

Aug
24
2 months ago
Activity icon

Replied to Array_map(): Expected Parameter 2 To Be An Array, Int Given

But why the validation know it as an error?

Activity icon

Replied to Array_map(): Expected Parameter 2 To Be An Array, Int Given

yes i delete that 2 line and it works

Activity icon

Replied to Array_map(): Expected Parameter 2 To Be An Array, Int Given

[2020-08-24 08:23:36] local.ERROR: array_map(): Expected parameter 2 to be an array, int given {"userId":1,"exception":"[object] (ErrorException(code: 0): array_map(): Expected parameter 2 to be an array, int given at /home/isamirsalehi/projects/tarh/vendor/laravel/framework/src/Illuminate/Validation/ValidationRuleParser.php:92)
[stacktrace]
#12 /home/isamirsalehi/projects/tarh/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php(111): call_user_func_array()
#13 /home/isamirsalehi/projects/tarh/app/Http/Controllers/Admin/User/AdminController.php(41): Illuminate\Http\Request->__call()
#14 [internal function]: App\Http\Controllers\Admin\User\AdminController->store()

line 41 is the first validation that is nationalCode but when i delete it the error still exists

Activity icon

Replied to Array_map(): Expected Parameter 2 To Be An Array, Int Given

I think that's not the problem but i tried what you said, unfortunately it doesn't work

Activity icon

Started a new Conversation Array_map(): Expected Parameter 2 To Be An Array, Int Given

Hi everyone!

When i send my data to store method i get the above error. this's my code in store method

$data = $request->validate([
            'nationalCode' => ['required', 'regex:/^[0-9]{10}$/', 'unique:users,nationalCode'],
            'username'     => "required|min:3|max:40|unique:users,username",
            'email'        => ['regex:/[^@][email protected][^\.]+\..+/', "unique:users,email"],
            'mobile'       => ['required','regex:/09(1[0-9]|3[1-9]|2[1-9])-?[0-9]{3}-?[0-9]{4}/',],
            'firstName'    => 'required|min:3|max:40',
            'lastName'     => 'required|min:3|max:40',
            'province'     => 'required',
            'role'         => 2,
            'isActive'     => 1,
        ]);

        // generate password automatically 
        $password =  bcrypt('password_star');

        $data += ['password' => $password];

        User::create($data);

        alert()->success('مدبر مورد نظر با موفقیت ایجاد شد', 'موفقیت آمیز');

        return redirect(route('admin.user.index'));

what should i do?

Aug
23
2 months ago
Activity icon

Started a new Conversation Add Extra Name To Behind Route Resource

Hi guys.

I have this route resource in my group function for admin:

Route::prefix('admin')->namespace('Admin')->middleware('auth')->group(function (){
    Route::resource('user', 'UserController');
});

I also have the same route resource name in another group function. i wanna add one extra name behind it to realize it easily as admin.user.*

What should i do?

Aug
20
2 months ago
Activity icon

Started a new Conversation How To Download File

Hi guys!

How can i give download link to user to download exists file in public directory?

Activity icon

Replied to Can't Get The Data Of Id In The Route

here is my edit method

 public function edit(DataType $dataType)
    {
        dd($dataType);
        return view('admin.basicDate.editDataType');
    }

route:

Route::prefix('admin')->namespace('Admin')->middleware('auth')->group(function (){
    Route::resource('data', 'DataTypeController'); // this is the route
    Route::resource('dataItem', 'DataItemController'); 
    Route::resource('config', 'ProjectConfigController');

    Route::get('projects', '[email protected]')->name('admin.projects');
    Route::post('project/{project}/confirmation', '[email protected]')->name('admin.confirmation');
});

Activity icon

Started a new Conversation Can't Get The Data Of Id In The Route

Hi guys, I hope you doing great

I'm using route resource but there's a problem, when i use edit route i can't get the data of the id in the route and it returns:

App\DataType {#1309 ▼
  #fillable: array:5 [▶]
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #changes: []
  #casts: []
  #classCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

What should i do for this?