engrlaravel

engrlaravel

Member Since 1 Year Ago

Experience Points
3,680
Total
Experience

1,320 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
1
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
3,680 XP
Apr
08
7 hours ago
Activity icon

Started a new Conversation Send Email To Multiple Users In Loop

Hi have below code, i am using to send email to one user, How i can send it to multiple users?

Do i need to clear it after sending to one user?

foreach ($task->users as $user)
{
 $subject = $user->subject;
 $email = $user->email;
 $template_data = "any text";
  Mail::send([], [],
                        function ($message) use ($subject,$email,$template_data) {
                            $message->to($email)
                                ->from('[email protected]')
                                ->subject($subject)
                                ->setBody($template_data, 'text/html');
                        });
}
Apr
05
3 days ago
Activity icon

Replied to Laravel Scheduling Or Task Scheduling

@snapey : How i can create the job first in laravel? i guess there are many ways to do but i am not sure which one is best

Mar
31
1 week ago
Activity icon

Replied to Laravel Scheduling Or Task Scheduling

this will not work, is there any alternative?

Activity icon

Replied to Select All Records Where Due_date = Tomorrow

@snapey @jeffreyvanrossum : Thank you for your reply, I am confused about this

echo Carbon::tomorrow();   //2020-04-01 00:00:00

so Carbon::tomorrow(); print with time also. will it effect my result? what if it print 2020-04-01 01:00:00

then ??

Mar
30
1 week ago
Activity icon

Replied to Select All Records Where Due_date = Tomorrow

@snapey : Yes due_date = "2020-03-31 02:05:50". I mean expiring tomorrow.

Basically, i want to send reminder to users that your deal is expiring tomorrow to be remind.

It will be better if my query ignore time part of where condition

Activity icon

Started a new Conversation Select All Records Where Due_date = Tomorrow

I want to select all records who is expiring tomorrow. I have due_date (Y-m-d H:i:s) format,

   $tasks = Task::where('deleted_at', null)
        ->where('due_date', '>=', Carbon::tomorrow())->get();

i tried this but it will not work.

It should be irrespective of time.

Activity icon

Started a new Conversation Laravel Scheduling Or Task Scheduling

I want to send emails on expiry dates data in table. I want to run scheduler every five minutes.

I am using Windows Server for my website, so i can not use this command

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

what is alternative i can use?

Mar
26
1 week ago
Activity icon

Started a new Conversation Laravel Eloquent Problem

I have below query

 $tasks = Task::where('deleted_at', null)->where('status',0);
 $tasks = $tasks->orWhereIn('id',$task_ids);

Generated query

 SELECT * FROM `tasks` WHERE `deleted_at` IS NULL AND `status` = 0 OR `id` IN (80,101,107,112,113,133,134,184) ORDER BY `id`
  DESC

Problem is there are some task ids (113,133,134) who status =2. I want only to get all records of status =0 even it is IN condition.

Mar
24
2 weeks ago
Activity icon

Started a new Conversation Running Scheduling Tasks In Laravel On Windows Server

How to create cron jobs or schedule tasks on windows server?

I want to run a script/function every minute, what is best option?

Mar
07
1 month ago
Activity icon

Replied to How To Find Top Most Parent?

It do not help as it is not for multi level children, is there anything in laravel relationship or loop to get it?

Activity icon

Started a new Conversation How To Find Top Most Parent?

I want to get the only one Top most parent for any record. Here is my code

id  | cat_name      | cat_parent_id
 --- | --------------| ------------- 
1   | Parent Cat 1  | NULL 
2   | Parent Cat 2  | NULL 
3   | Child Cat 1   | 2 
4   | Child Cat 2   | 2 
5   | Parent Cat 3  | NULL 
6   | Child Cat 3   | 5
7   | Child-Child Cat 2 | 4


Parent Cat 1
Parent Cat 2
    Child Cat 1
    Child Cat 2
       Child-Child Cat 2
Parent Cat 3
    Child Cat 3


 public function parent() {
  return $this->belongsToOne(static::class, 'cat_parent_id');
}


  public function children() {
    return $this->hasMany(static::class, 'cat_parent_id')->orderBy('cat_name', 'asc');
  }

So for Child-Child Cat 2 , I want to get Child Cat 2

Example

FindTopParentId(7)  // so it will return me 2
Feb
24
1 month ago
Activity icon

Started a new Conversation Laravel- Eloquent: Find Nth Level Children

I want to find un-limited children for a parent in same table, here is my code

Note: I will pass one Id to find all its inner children. For example FindChildren(2)

id  | cat_name      | cat_parent_id
--- | --------------| ------------- 
1   | Parent Cat 1  | NULL 
2   | Parent Cat 2  | NULL 
3   | Child Cat 1   | 2 
4   | Child Cat 2   | 2 
5   | Parent Cat 3  | NULL 
6   | Child Cat 3   | 5
7   | Child-Child Cat 2 | 4


Parent Cat 1
Parent Cat 2
    Child Cat 1
    Child Cat 2
        Child-Child Cat 2
Parent Cat 3
    Child Cat 3


    public function parent() {
      return $this->belongsToOne(static::class, 'cat_parent_id');
    }

  //each category might have multiple children
    public function children() {
        return $this->hasMany(static::class, 'cat_parent_id')->orderBy('cat_name', 'asc');
    }
Dec
19
3 months ago
Activity icon

Started a new Conversation MongoDB Package For Laravel - Issue

I want to install jenssegers/laravel-mongodb package on laravel, i am getting this error

Your requirements could not be resolved to an installable set of packages.

jenssegers/mongodb v3.6.0 requires mongodb/mongodb ^1.4 -> satisfiable by mongodb/mongodb

and many other lines, at the end it says

   Installation request for jenssegers/mongodb ^3.6 -> satisfiable by jenssegers/mongodb[v3.6.0, v3.6.1].

Note: I am using laravel 6 and

 php_mongodb-1.6.1-7.2-ts-vc15-x64 dll

and php 7.2.x and MongoDB extension version = 1.6.1

Dec
12
3 months ago
Activity icon

Replied to Push Code To Server/ Deploy To Server

@sinnbeck : What is best practice in market? (for other than alibaba as well). or other than laravel project.

Activity icon

Started a new Conversation Push Code To Server/ Deploy To Server

I am pushing my code to git (bitbucket). and then login to remote server and pull code from git.

Is there anyother better way so that i can deploy directly?

I want my developers to deploy his code without login to remote server again and again.

Please suggest me all possible ways. I am using Alibaba cloud

Activity icon

Replied to GroupBy And Count On Laravel Eloquent Collection

@tisuchi : I think this will not give me separate count for type and status.

I was thinking to get collection first and then apply groupBy and Count on it

Activity icon

Started a new Conversation GroupBy And Count On Laravel Eloquent Collection

I have main query

$tasks  = Task::where('deleted_at', null)->where('companyId',$c_id)->get();

Now i want to get these results

1- I want to get status and its count like,

 select status,total_count from tasks groupBy('status')

2- I want to get type and its count like

select type,total_count from tasks groupBy('type')

This can be down by 2 queries, BUT i want to optimize it.

Is it possible to do with collection or one query?

Dec
11
3 months ago
Activity icon

Replied to Laravel Eloquent WHEREIN Not Working

@sinnbeck : If i pass EMPTY then show nothing

By the way, why i can get result of this query?

SELECT * FROM `tasks` WHERE  `status` = 'EMPTY'

I do not have EMPTY in status field

Activity icon

Replied to Laravel Eloquent WHEREIN Not Working

@sinnbeck : I am receiving status as below

 0 or 1 or 2 or EMPTY

Then how i can put check? I tried this but still now working

if($request->input('status'))
        {
            if (strpos($request->input('status'), ',') !== false) {
                $tasks->whereIn('status', explode(',',$request->input('status')));
            }else{
                $tasks->where('status', $request->input('status'));
            }
        }
Activity icon

Replied to Laravel Eloquent WHEREIN Not Working

@stereoh :

$request->input('status') is comma separated string and i am using explode php function to convert to array

Activity icon

Started a new Conversation Laravel Eloquent WHEREIN Not Working

I have a simple query

$tasks->whereIn('status', explode(',',$request->input('status')));

where $request->input('status') = 0,1,2 (comma separated string)

In Database status only has 0,1,2. when i pass EMPTY it also show me all result.

SELECT * FROM tasks WHERE status IN ('EMPTY')

although there is no EMPTY value in status

Dec
07
4 months ago
Activity icon

Replied to Laravel 6, CORS Problem

@bobbybouwmann : It seem to be simple but its not working for me. I am using full laravel (not lumen) and creating api.

Should i remove the above code i have done before i implement this package? is there any example done for this package?

Dec
05
4 months ago
Activity icon

Started a new Conversation Laravel 6, CORS Problem

Here is what i tried

My middlewhare is

 return $next($request)
    ->header('Access-Control-Allow-Origin', '*')
    ->header('Access-Control-Allow-Credentials', 'true')
    ->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Authorization, X-Requested-With, Accept, X-Token-Auth, Application')
    ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');

My api route is here

Route::group(['middleware' => ['cors', 'auth:api']], function() {
Route::options('{any}');
Route::post('user/profile','[email protected]');

In Kernel

protected $routeMiddleware = [


'cors' => \App\Http\Middleware\Cors::class,

But still i am getting this error in api call from another origin

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any reason?

Activity icon

Replied to API Authentication, Return Error Message

I was surprised, when i changed Accept to application/json in postman,it worked well

Dec
04
4 months ago
Activity icon

Started a new Conversation API Authentication, Return Error Message

I am using api_token for authentication in laravel api using this document

https://laravel.com/docs/6.x/api-authentication

when i post my token with Bearer in postman, & the token is wrong, instead of error message i am getting

Symfony\Component\Routing\Exception\RouteNotFoundException: Route [login] not defined.

How i can get unauthorized error message?

Activity icon

Started a new Conversation Laravel Permission & Roles In Api

I am using laravel package laravel-permission

I am creating api in laravel to return json data.

How i can get a user roles & permissions? there is no login system in api, i can only get userId

How this can be done?

Activity icon

Awarded Best Reply on IIS, Laravel Route Not Found Issue

It was my bad, i just went to url rewrite and removed the previous/old rules. now it is working

Activity icon

Replied to IIS, Laravel Route Not Found Issue

It was my bad, i just went to url rewrite and removed the previous/old rules. now it is working

Activity icon

Replied to IIS, Laravel Route Not Found Issue

@nakov : Yes my physical path is

C:\inetpub\wwwroot\BackendAPI\public

and above web.config file location is C:\inetpub\wwwroot\BackendAPI\public

Activity icon

Replied to IIS, Laravel Route Not Found Issue

@nakov : I have a laravel website www.example.com. I want to create another laravel api application, it will be like www.example.com/backendapi/

till here it is working fine, but now it do not work for other routes like www.example.com/backendapi/test

any solution?

Activity icon

Replied to IIS, Laravel Route Not Found Issue

@nakov : I updated my question. I read all these but no luck.

Is it possible to add another laravel website as Application to an already existing laravel website?

Activity icon

Started a new Conversation IIS, Laravel Route Not Found Issue

I have installed my application in Sites on iis. Sites->example.com->add application.

The default route is working and all other routes not working.

public/web.config is here

         <configuration>
            <system.webServer>
           <directoryBrowse enabled="true" />
         <rewrite>
      <rules>
        <rule name="Rule 1" stopProcessing="true">
          <match url="^(.*)/$" ignoreCase="false" />
          <action type="Redirect" redirectType="Permanent" url="/{R:1}" />
        </rule>
        <rule name="Rule 2" stopProcessing="true">
          <match url="^" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php" />
        </rule>
      </rules>
    </rewrite>
          </system.webServer>
         </configuration>

web.php

Route::get('/', function () {
    echo " web.php / method";
});

 Route::get('/test', function () {
     echo "web/test";
});

the first is working and 2nd do not work.

what could be the issue?

Nov
28
4 months ago
Activity icon

Started a new Conversation What Is The Main Difference Between Symfony And Laravel PHP Framework?

I know this question has been asked many time on internet, But still i am not clear.

I am laravel developer, Do i still need to learn symfony?

If someone need symfony developer, can i apply for that job?

For laravel developer, what is different and difficult if he want to move to symfony?

What are the plus points symfony have while laravel don't?

Nov
24
4 months ago
Activity icon

Started a new Conversation MongoDB With Laravel

I am not sure if this is right place to ask this type of question.

I want to use mongodb with laravel.

Is there any free UI tool for MongoDB as phpmyadmin/SQLyog ??

which laravel package is best for mongodb?

Nov
20
4 months ago
Activity icon

Replied to Laravel Eloquent Array

@sinnbeck : here is it

public function entities()
{
    return $this->hasMany('App\TopicTaskRelationship', 'topic_id')->groupBy('listing_id');
}

where TopicTaskRelationship has (id,listing_id,type....)

Activity icon

Started a new Conversation Laravel Eloquent Array

I have this code

 $entitles_ids = $arr->entities ? $arr->entities->pluck('listing_id','type')->all() : '';

I want to get this result

 if(type == 0)
 {

 $entitles_ids = [
                Report-3,
                Reprot-4
 ]

 }else if(type == 1)
 {

   $entitles_ids = [
                MOM-3,
                MOM-4
 ]
 }else{}

where 3 & 4 are listing_id

Activity icon

Replied to Separation Of Front End And Backend In Laravel

@jlrdw @fylzero : Basically i do not want to give them full source code, they can copy paste my whole project & can sell it. Is there a better option

Nov
19
4 months ago
Activity icon

Started a new Conversation Separation Of Front End And Backend In Laravel

I have a situation, I have 2 teams , front end & back end. I want to give access to them. I want front end to have only access to front end code/files & backend team to only back end related files.

I am using laravel 5.6 and jquery/javascript & bootstrap.

Is it possible in laravel? or it can be done by git? BTW, i am using bitbucket.

Any good idea?

Nov
17
4 months ago
Activity icon

Replied to Getting Result Based On Other Table

@tykus Models & tables exact names are below

1- Task = tasks (table name)

2- Report = work_reports (table name)

3- TopicTaskRelationship = topic_task_relationship (table name)

Activity icon

Replied to Getting Result Based On Other Table

@tykus : which type of relationship should i create in models for them?

Activity icon

Started a new Conversation Getting Result Based On Other Table

I have 3 tables

reports(id,title,department_id)

tasks(id, title, status, created_at)

task_relationship(id,task_id,report_id,type)

I want to select result for below conditions

1- I want to select all tasks with status=0

2- department_id = 2

3- type = 2

Department_id is in reports and their relation is saved in task_relationship table.

Can it be achieved by eloquent?

Oct
21
5 months ago
Activity icon

Replied to Laravel Cron Jobs/ Task Scheduling

@sinnbeck : what is best way to create laravel scheduling? there are many ways which is confusing.

Example: Closure & Commands

Activity icon

Started a new Conversation Laravel Cron Jobs/ Task Scheduling

I am using IIS server to run laravel website. How i can create task scheduling on windows IIS server?

On linux server it is asking to run this commond, but how to do in window?

          • cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Oct
20
5 months ago
Activity icon

Started a new Conversation Redis Vs Memcached In Laravel

I want to implement cache in laravel. Which one should i pick? Redis or Memcached?

I know this is very common question, but still it is not clear.

I read complete details on internet but its still confusing. I will consider speed & storage.

Oct
13
5 months ago
Activity icon

Replied to Laravel - Access Denied Issue

I do not know what was the issue with root. I created new user with % as host and its working fine

Activity icon

Replied to Laravel - Access Denied Issue

@geowrge : Please note, i created one php file outside laravel application and test connection. i can connect to DB with same credentials

Activity icon

Started a new Conversation Laravel - Access Denied Issue

I migrated my PHP website to Windows server IIS. Now i am getting this error

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

Here is my .env file details

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=mydbname
DB_USERNAME=root
DB_PASSWORD=mypwdhere

I also clear config by command

php artisan config:clear

I am using mysql workbench 8 & accessing directly like http://localhost/myapp/admin/login

what can be the issue?

Oct
09
5 months ago
Activity icon

Started a new Conversation Avoid Application Crash In Laravel

In laravel, if there is any error or bug, it crash the application and showing black error code screen.

How can i show some user friendly page to user if there is any crash or error?