engrlaravel

engrlaravel

Member Since 1 Year Ago

Experience Points
3,280
Total
Experience

1,720 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-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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,280 XP
Dec
19
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
1 month 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
2 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
2 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
2 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
2 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
3 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
3 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
3 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
3 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?

Sep
30
3 months ago
Activity icon

Replied to Add Dynamic Prefix In Laravel Routes Web.php

@mikemacdowell : Then what is the best way to do it?

Activity icon

Replied to Using Cache In Laravel

@sti3bas : thank you for your reply.

I can see this on documentation "Predis has been abandoned by the package's original author and may be removed from Laravel in a future release."

So what alternative we should use?

What about mencached? how that can be configured on server?

Activity icon

Replied to Using Cache In Laravel

@sti3bas : Once Redis is installed, what extra changes/configurations do i need on laravel & DB side?

Also for Memcached, do i need to install on server?

Activity icon

Started a new Conversation Using Cache In Laravel

I am using laravel 5.8. I know laravel support memcached & redis. If i go for Redis, what should i do? Do i need to buy something for my hosting??

How to get these values?

'redis' => [

'client' => 'predis',

'default' => [
    'host' => env('REDIS_HOST', '127.0.0.1'),
    'password' => env('REDIS_PASSWORD', null),
    'port' => env('REDIS_PORT', 6379),
    'database' => env('REDIS_DB', 0),
],

'cache' => [
    'host' => env('REDIS_HOST', '127.0.0.1'),
    'password' => env('REDIS_PASSWORD', null),
    'port' => env('REDIS_PORT', 6379),
    'database' => env('REDIS_CACHE_DB', 1),
],

],

I am new to it. Can anyone explain step by step what should i do?

I have doubt i should buy/configure on my hosting as well? do i need to buy server for it?

Activity icon

Replied to Add Dynamic Prefix In Laravel Routes Web.php

@mikemacdowell : Simply, I just want to create url having each company name who is using my application( who is registered with me).

For example, If you are login(assume your company name is mikemacdowell) so the route will be example.com/mikemacdowell/.....

and if i am login(company name is laravel) so example.com/laravel/......

Activity icon

Started a new Conversation Add Dynamic Prefix In Laravel Routes Web.php

I have below code example in my web.php

Route::group(['prefix'=>'admin'],function (){

Route::group(['prefix' => 'admin','middleware' => 'auth'], function () {

Route::group(['prefix' => 'candidate','middleware' => 'auth'], function () {


Route::get('login', 'frontend\[email protected]');

Route::get('/home', '[email protected]')->name('home');

I have some group & some with out groups.

Questions:

1- How to get dynamic value from DB

2- How i can add that value prefix before all above?

Example

example.com/company_name/admin

example.com/company_name/home
Sep
25
4 months ago
Activity icon

Started a new Conversation Workflow Process Design & Automation With Web Forms In Php - Laravel

Is there any PHP / Laravel workflow generator, same as https://www.workflowgen.com/ in DOTNET?

Sep
24
4 months ago
Activity icon

Replied to Laravel Eloquent JOINS & Relationships Issue

@tisuchi : I have tried below

public function vacancies()
{
   return $this->hasManyThrough('App\Vacancy', 'App\PlanPosition','plan_id','position_id','','position_id');
}


and now it is working
Sep
23
4 months ago
Activity icon

Replied to Laravel Eloquent JOINS & Relationships Issue

@tisuchi : thank you for your answer.

I have only this relation

public function positions()
{
 return $this->hasMany('App\PlanPosition', 'plan_id');
}

Can you tell me what relationship should i have between PlanPosition & Vacancy? Both tables have position_id

Activity icon

Started a new Conversation Laravel Eloquent JOINS & Relationships Issue

I have below tables/models

Plan(id,created_by)
PlanPosition(id,plan_id,position_id)
Vacancy(id,position_id)

I have this relation in Plan

public function positions()
{
    return $this->hasMany('App\PlanPosition', 'plan_id');
}

Now i want to do the following

 select all records from first 2 tables where plan.created_by = 7

AND

AND is not exist in vacancy

Is there any cleaner way to do it in laravel?

Sep
22
4 months ago
Activity icon

Replied to Relationship With Many Where Condition

@mstrauss : your approach is much cleaner. what about this one?

    Interview::where('created_by',Auth::user()->id)->where('company_id',Auth::user()->company_id)
                ->orWhereHas('attendees', function ($query) {
                    $query->where('interviewer_id', Auth::user()->id);
                })->get();
Activity icon

Started a new Conversation Relationship With Many Where Condition

I have below tables/models

Interview (id,subject,created_by)
InterviewAttendee(id,interview_id,interviewer_id)

Here is my relationship to get attendees for any interview

   public function attendees()
{
    return $this->hasMany('App\InterviewAttendee', 'interview_id');
}

Now i want to select all interview (interviews table) which satisfy any of below conditions

 1- Auth::user()->id = interviews.created_by
 2- Login user has role = "HR"
 3- Auth::user()->id  = InterviewAttendee.interviewer_id

Can anyone suggest how to do it smoothly?

Sep
16
4 months ago
Activity icon

Started a new Conversation Best Way To Stop Users Directly Access Url

I am using below package in laravel

laravel-permission

If user is login, He can access links of different roles not assigned to him. The only two ways to stop him is

public function __construct()
{
    $this->middleware(['role_or_permission:Admin|HR|HRM']);
}

OR

Route::group(['middleware' => ['role_or_permission:super-admin|edit articles']], function () {

Now the problem is, what if new role or permission created which is not mentioned here??

also you can not mention a long list of roles & permissions one by one.

Is there a better way?

Activity icon

Replied to Best Way For Sub Apps In Laravel

@martinbean : Yes, till this point is clear. The issue is how we handle company slug in url prefix?

Currently i have below groups in web.php

Route::group(['prefix'=>'admin'],function (){
Route::group(['prefix'=>'candidate'],function (){

Currently my url is

example.com/admin

I need to change to

 example.com/apple/admin
 example.com/apple/candidate

How to prefix company slug ?