RamjithAp

RamjithAp

Software Developer at Saggezza Inc.

Bangalore

Member Since 1 Year Ago

Experience Points 40,430
Experience
Level
Lessons Completed 1
Lessons
Completed
Best Reply Awards 64
Best Answer
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.

04 Dec
1 week ago

RamjithAp left a reply on How To Add Validations On My Login Page

In your LoginController.php add this method

protected function authenticated(Request $request, $user)
{
if ( $user->verification_status ==0 ) {
    Auth::logout();
        return redirect('/login')->with('error','verify status first');
}
 return redirect('/home');
}

In your view login.blage.php

@if(session()->has('error'))
    <div class="alert alert-danger">
        {{ session()->get('error') }}
    </div>
@endif
15 Nov
4 weeks ago

RamjithAp left a reply on Failed To Open Stream: No Such File Or Directory In File

Create folder if not exist before use fopen(). Try this

$dirname = dirname($filename);
if (!is_dir($dirname))
{
    mkdir($dirname, 0755, true);
}
$file = fopen($path . $filename, 'wb'); 
29 Oct
1 month ago

RamjithAp left a reply on Unlink Files Fron Public Directory

Use the unlink function of php, just pass the exact path to your file to unlink function :

unlink($file_path);

Do not forget to create a complete path of your file if it is not stored in the DB. e.g

$file_path = app_path().'/path-to-file;

RamjithAp left a reply on How To Display Json In Blade Laravel

You never going to get answers until you realize what you doing.

Learn https://laravel.com/docs/5.7/eloquent-relationships

After that, you can fix your problems.

26 Oct
1 month ago

RamjithAp left a reply on 405 Method Not Allowed

php artisan route:list

See, If the DELETE request you are trying to send is allowed in the routes or not. You can also try to

route:clear

to clear the route cache.

RamjithAp left a reply on How To Highlight Current Menu Item In Bootstrap?

Just make sure your URL is correct or change below code accordingly

@if(Request::is('vehicles/myads')) active @endif

RamjithAp left a reply on How To Highlight Current Menu Item In Bootstrap?

Try this

 <div class="list-group">
    <a href="{{route('vehicles.myads')}}" class="list-group-item @if(Request::is('vehicles/myads')) active @endif" ><i class="fa fa-credit-card"></i> <span>My Ads</span></a>

RamjithAp left a reply on Laravel Route

Link your CSS and js file like below

     <link href="{{ asset('css/style.css') }}" rel="stylesheet">
    <script type="text/javascript" src="{{url('/') }}/js/app.js"></script>

RamjithAp left a reply on Getting Data Back To Javascript From Laravel Controller

Accept the answer if that fixed.

RamjithAp left a reply on Getting Data Back To Javascript From Laravel Controller

Try changing your token name as below. Use this in the head section:

<meta name="csrf-token" content="{{ csrf_token() }}">

and get the csrf token in ajax:

$.ajaxSetup({
  headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
});

Please refer Laravel Documentation https://laravel.com/docs/5.6/csrf#csrf-x-csrf-token

RamjithAp left a reply on Getting Data Back To Javascript From Laravel Controller

Try changing your tkone name as below. Use this in the head section:

<meta name="csrf-token" content="{{ csrf_token() }}">

and get the csrf token in ajax:

$.ajaxSetup({
  headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }
});

Please refer Laravel Documentation https://laravel.com/docs/5.6/csrf#csrf-x-csrf-token

RamjithAp left a reply on Getting Data Back To Javascript From Laravel Controller

Under the network, tab click on the upload request and check request tab & response tab.

RamjithAp left a reply on How To Write Code In Laracast?

Simply write code

RamjithAp left a reply on Getting Data Back To Javascript From Laravel Controller

Open your browser developer tools -> network section and check when to do the upload what request goes and what response comes.

RamjithAp left a reply on How To Display Json In Blade Laravel

Here is your first post - https://www.laracasts.com/discuss/channels/laravel/how-do-i-parse-this-json-data-in-view-blade?page=2#reply-466694

Problem is you saving ids of another table in JSON format in one column( not created relationship table). You want to pull the property of the mapped ids which saved in a column as JSON without looping the JSON and write query for each id. You never going to get the values of "id" & "title" unless you save the ids in the relationship table or separate column or loop and query.

RamjithAp left a reply on Getting Data Back To Javascript From Laravel Controller

Try

public function support(Request $request){
      return response()->json(['url'=> '/public/images/test/IMG_1579.jpg']);
    }

And

   success: function(data) {
            $(el).summernote('editor.insertImage', data.url);
        }
24 Oct
1 month ago

RamjithAp left a reply on Display JSON

You cannot write relationship for json data which saved in a column. You need to use pivot table to save infractions relation. Or you have to loop through jain data and write query to pull infractions details.

RamjithAp left a reply on Display JSON

But id and title data not there. Where do you saving the.m.

RamjithAp left a reply on Display JSON

Still, your infraction_data column has only numbers in it, I do not see any id or title data. So you cannot get id from that table.

RamjithAp left a reply on Store Radio Buttons Data

Migration table something like this

public function up()
{
    Schema::create('table_name', function (Blueprint $table) 
    {
        $table->TinyInteger('question',1);

    }); 

}

And view

    <div class="col-md-3" >
                        <legend >All suspensive conditions met?</legend>
                        <div class="col-sm-10">
                            <div class="form-check float-left" >
                                <input class="form-check-input" value="1" type="radio" name="question" id="gridRadios1" value="option1" required>
                                <label class="form-check-label" for="gridRadios1">Yes</label>
                            </div>
                            <div class="form-check float-left">
                                <input class="form-check-input" value="0"  type="radio" name="question" id="gridRadios2" value="option2" required>
                                <label class="form-check-label" for="gridRadios2">No</label>
                            </div>
                        </div>
                    </div>

RamjithAp left a reply on Maximum Function Nesting Level Of '512' Reached, Aborting!

Increase the limit as per your convenient count. Or disable nesting level limit itself.

RamjithAp left a reply on Display JSON

As you see you trying to get an object "id" but there is no such object exist in the inspection_data.

If you explain what id, title you trying to fetch with above numbers we can help.

RamjithAp left a reply on Maximum Function Nesting Level Of '512' Reached, Aborting!

Add this line before your code

ini_set('xdebug.max_nesting_level', 1000);

RamjithAp left a reply on Display JSON

Can you please print and show the data in $inspection->inspections_data.

print_r($inspection->inspections_data);

RamjithAp left a reply on Display JSON

Where do you using this function htmlspecialchars() ?

RamjithAp left a reply on Display JSON

Do json encode and then decode

  @foreach($inspections as $inspection)
    <?php $inspection_data = json_decode(json_encode($inspection->inspections_data),TRUE); ?>
    <tr>
        <td>{{ $inspection_data["id"] }}</td>
        <td>{{ $inspection_data ["title"] }}</td>
    </tr>
@endforeach 

RamjithAp left a reply on How To Access Json Data

You can access like below

 foreach ($content as $character) {
             foreach ($character["photos"] as $photo) {
            echo $photo["height"] . '<br>';
echo $photo["width"] . '<br>';
echo $photo["src"]["original"] . '<br>';
        }
        }

RamjithAp left a reply on When I Integrate SSH It's Give Me Error Password / Key Is Required.

Check with your server hosting provider or get it from hosting control panel.

RamjithAp left a reply on Display JSON

use

->whereNotNull('infraction_data')->first(); 

RamjithAp left a reply on How To Access Json Data

Since you did json_decode now the $content is an array. So you can access it with square brackets

 foreach ($content as $character) {
            echo $character["total_results"] . '<br>';
        }

RamjithAp left a reply on How Can I Get Username Who Has Same Project With User Logged In

Show you complete User.php model codes.

RamjithAp left a reply on How Can I Get Username Who Has Same Project With User Logged In

In your Project model

public function users() {
    return $this->belongsToMany('user_projects','user_id','project_id');
}

And in your view

        <table class="table table-consended">
                    <tr>
                        <th> <h4>No</h4> </th>
                        <th> <h4>Name</h4> </th>
                        <th> <h4>Role</h4> </th>
                        <th> <h4>Project</h4> </th>
                    </tr>
                    @foreach($users as $item => $user)                        
                    <tr>
                        <td>{{$item+1}}</td>
                        <td>{{$user->name}}</td>
                        <td>{{$user->role->name}}</td>
                        <td>
                            @foreach ($user->projects as $project)
                                {{$project->project_name}}
                                 //Here you can pull all the username who has project same as logged user
                        @foreach ($project->users as $u)
                                {{$u->username}}
                                @endforeach
                            @endforeach
                        </td>
                    </tr>
                    @endforeach()
                </table>
23 Oct
1 month ago

RamjithAp left a reply on How Can I Get Multiple Dynamic Products In Dynamic Pages On Laravel

If you want to loop only child class div then in your content table you must save only this

       <div class="child">
                           {id}
                           {p_name}
                           {p_slug}
                           {b_name}
                           {b_slug}
                           {img_src}
                           {sale_price}
                           {regural_price}
                           {sale_tag}
                           {featured_tag}
                           {rating}
                           {type == 0}   
                 </div>

also your controller should loop the content as below

     //here i am using Query For Getting Products
    //make html codes
    if(!empty($result)){
        //shortcodes
        $shortcodes[] = [
            '{id}','{p_name}','{p_slug}','{b_name}','{b_slug}','{img_src}','{sale_price}','{regural_price}','{sale_tag}','{featured_tag}','{rating}','{type == 0}',
        ];
        $temp_content = '';
        foreach($result as $row){
            if($row->featured_product == 0){
                $featured = '<span class="tg-themetag" style="margin-left: 15px;">Featured</span>';
            }else{
                $featured = '';
            }

            //shortcodes_data
            $shortcodes_data[] = [
                '{id}' => $row->p_id,
                '{p_name}' => $row->p_name,
                '{p_slug}' => $row->p_slug,
                '{b_name}' => $row->b_name,
                '{b_slug}' => $row->b_slug,
                '{img_src}' => URL('public/assets/user/images/ecommerce/products/'.$row->featured_image),
                '{sale_price}' => $row->sale_price,
                '{regural_price}' => $row->regural_price,
                '{sale_tag}' => 'Sale',
                '{featured_tag}' => $featured,
                '{rating}' => '5',
                '{type == 0}' => ' ',
            ];
        $temp_content. =  str_replace($shortcodes, $shortcodes_data, $content->content);
        }
    } 
    $content->content = $temp_content;
    return $content;

RamjithAp left a reply on How Can I Get Multiple Dynamic Products In Dynamic Pages On Laravel

Show us the code which you iterate products loop.

RamjithAp left a reply on Debug Auth

Place this in your loginController.php file

public function authenticate(Request $request)
         {
            $input=$request->all();
            $password=$input['password'];
            $name=$input['name'];

            if (Auth::attempt(['Name' => $name, 'Password' => $password]) ){
            return redirect()->intended('/home');
        }   else 
          {
                return redirect('/login')->with('message','Error logging in!');
            }
        }

RamjithAp left a reply on Undefined Variable: Tags

Your controller should have create method

class TagController extends Controller
{
    public function index()
    {
        $tags = Tag::all();
        return view('tags.index',compact('tags'));
    }

  public function create()
    {
        $tags = Tag::all();
        return view('tags.create',compact('tags'));
    }

    public function store(Request $request)
    {
        $this -> validate($request, array(
            'name' => 'required | max:50',
        ));

        $tags = New Tag;
        $tags -> name = $request -> name;
        $tags -> save();

        return redirect() -> route('tags.index', $tags->id) -> withMessage('برچسب شما با موفقیت ایجاد شد!');
    }

    public function show($id)
    {
        $tags = Tag::find($id);
        return view('tags.show',compact('tags'));
    }


    public function edit($id)
    {
        $tags = Tag::find($id);
        return view('tags.edit',compact('tags'));
    }

    public function update(Request $request, $id)
    {
        $this -> validate(
            $request, array(
            'name' => 'required | max:50',
        )
    );

        $tags = Tag::find($id);
        $tags -> name = $request -> input('name');
        $tags -> save();

        return redirect() -> route('tags.index', $tags->id) -> withMessage('برچسب شما با موفقیت ویرایش شد!');
    }

    public function destroy($id)
    {
        $tags = Tag::find($id);
        $tags -> delete();

        return redirect()-> route('tags.index') -> withMessage('برچسب شما با موفقیت حذف شد.');
    }
}

RamjithAp left a reply on Debug Auth

Show us your loginController.php?

RamjithAp left a reply on How To Assign Temporary Data To Eloquent Model?

You can use this method directly and define the fillable array properly in your model will protect from update issue.

protected $fillable = ['name'];
$dog->totalWeekendsAlive = $totalWeekendsAlive;
$dog->save(); 

RamjithAp left a reply on How To Pass URL

Assuming your controller code at ControllerName.php

Create URL in your routes/web.php

Route::get('calender','[email protected]');

RamjithAp left a reply on Debug Auth

Basically, the registration controller looks like this

        $user = User::create(request(['name', 'email', 'password']));
        
        auth()->login($user);
        
        return redirect()->to('/home');

If you notice the above function, manually logging in the user after registration, but in your auth login function email_verified_at check is there. That's the difference.

You can override the registration function like below

        $user = User::create(request(['name', 'email', 'password']));
        
        return redirect()->back()->with('message','Registration successful check your mail for activation link.');
22 Oct
1 month ago

RamjithAp left a reply on Passing Variables From Controller To Provider

User View::share('data',$data);

In your provider

$data["courses"] = $courses;
$data["id"] = $id;
$data["client"] = $client;
$data["clients"] = $clients;
View::share('data',$data);

Now you can fetch them any where in your application

{{ $data["courses]}}

RamjithAp left a reply on Auth Credentials

You have an email_verified_at column at users table, which causing the problem.

Fix 1: Manually change email_verified_at column with some datetime(2018-10-22 10:10:02)

OR

Fix 2: Configure your email SMTP details properly which will send verification email to users so by clicking on the verification email users can activate the account.

19 Oct
1 month ago

RamjithAp left a reply on Guys How To Use Default Values User Model Laravel?

Simple set your table column default value like this

ALTER TABLE users ALTER COLUMN user_type SET DEFAULT 'job seeker';

Or in your controller before insert

$inputs = $request->all();
$inputs["user_type"] = "job seeker";
User::create($inputs);

Or the other one which I mentioned in the first reply.

RamjithAp left a reply on Guys How To Use Default Values User Model Laravel?

In your user model place this

/**
 * The "booting" method of the model.
 *
 * @return void
 */
protected static function boot()
{
    parent::boot();

    // auto-sets values on creation
    static::creating(function ($query) {
        $query->user_type= 'job seeker';
    });
}

RamjithAp left a reply on User Not Logged Out After Session Timeout

Use 'web' middleware'.

RamjithAp left a reply on Validation On Update: Unique

Use sometimes!

In your Model

protected $rules = [
    'email_address' => 'sometimes|required|email|unique:users',
    ..
];

In your Controller, action:update

...
$rules = User::$rules;
$rules['email_address'] = $rules['email_address'] . ',id,' . $id;
$validationCertificate  = Validator::make($input, $rules); 

RamjithAp left a reply on Cron Job

Step 1 Login into your webserver using SSH (If shared hosting use control panel) and add this cron entry

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

Above CRON will execute your laravel artisan file everyminute.

Step 2 Now go to your App\Console\Kernel.php and write this code inside schedule block

$schedule->call(function () {
            DB::table('recent_users')->delete();
        })->daily();

Above code will delete all the data from recent users table every day at midnight. So now place your email sending or whatever sending codes there and set the job frequency( available frequency here https://laravel.com/docs/5.7/scheduling#schedule-frequency-options ). Done!