leviathanz

Member Since 7 Months Ago

Experience Points
900
Total
Experience

4,100 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.

  • Community Pillar

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

Level 1
900 XP
Mar
05
17 hours ago
Activity icon

Replied to Return Redirect Multiple Condition

Big thanks you save my day, so why this happened?

Activity icon

Replied to Return Redirect Multiple Condition

try this and printed ^ "it works". On your previous questions is return to index not member. I am afraid is something wrong in my code: here the route for members page

Route::get('/member-card', ['as' => 'editor.member-card.index', 'uses' => '[email protected]']);
Route::get('/member-card/data', ['as' => 'editor.member-card.data', 'uses' => '[email protected]']);

Activity icon

Replied to Return Redirect Multiple Condition

Hi @neilstee , yes the conditions is met, the route also exist and no middleware attached on it. here the print if I used dd

^ {#1441 ▼
  +"count_members": 0
}
Activity icon

Started a new Conversation Return Redirect Multiple Condition

Hi All,

I have a condition in my laravel controller to redirect user to change default password complete their profile, with this code:

.......
        if ((Auth::user()->password_changet == null)) { //Default Password
           return redirect('editor/user/'.$user_id.'/edit')->with('defaultPass', 'Please change your default pass');
        }
		else if ($count_community_members == 0) { //Members Count Data
           return redirect('editor/member-card')->with('members', 'Please add your members data');
        }else{
           return view ('editor.index', compact('count_community_members ''));    
        }

This code only works for change password condition, but the second conditions on community_members not working, is not redirect user to the members page.

I use this on the Home controller. Any suggestion?

Thanks

Feb
23
1 week ago
Activity icon

Replied to View Not Found

Thanks, this works!

Activity icon

Replied to View Not Found

Thanks for explanation. But still got error.

Activity icon

Started a new Conversation View Not Found

Return view not found

I tried to make return view in my controller:

           return view ('/user/'.$user_id.'/edit');
        }
        else{
           
            return view ('editor.index');    
        }```

with this route: 

```Route::get('/user/{id}/edit', ['as' => 'editor.user.edit', 'uses' => '[email protected]']);```

when I accessed it, I got: ```View [.user.11.edit] ```not found. (11 is the current user id logged in)

Is there any suggestion, to call the right in my controller return?

Thanks
Feb
12
3 weeks ago
Activity icon

Started a new Conversation Combined Json And Web In One Controller

What's is pros and cons if I combined return view blade and returnJson in one controller? Is this will affected to the speed on server consumption?

And what is the recommendation way to run web version and mobile app

Thanks,

Feb
08
3 weeks ago
Activity icon

Started a new Conversation Laravel Sessions To Access Webview

Hi All,

Is it possible to get sessions from mobile to access the Laravel page webview from mobile App? What I tried to to do is, the mobile App login using passport API, and than user can access another page in webview format.

Thanks

Jan
18
1 month ago
Activity icon

Replied to Upload Image Using Ajax POST

Finally solved this, Thanks All

Activity icon

Started a new Conversation Upload Image Using Ajax POST

Hi All, I tried to upload an image into the form using ajax method, here the my form code in blade file:

<form action="#" id="form" enctype='multipart/form-data' class="form-horizontal">
        {{ csrf_field() }}
        <div class="modal-header">
         <h4 class="modal-title">Data Form</h4>
       </div>
       <div class="modal-body"> 
         <div class="form-body">
 
            <div class="form-group">
              <label class="control-label col-md-4">Description</label>
              <div class="col-md-8">
                <input name="description" id="description" class="form-control" type="textarea">
				<small class="errorDescription hidden alert-danger"></small> 
              </div>
            </div> 
			
			<div class="form-group">
              <label class="control-label col-md-4">Price</label>
              <div class="col-md-8">
                <input name="price" id="price" class="form-control" type="number">
                <small class="errorPrice hidden alert-danger"></small> 
              </div>
            </div>

			<div class="form-group"> 
			   <input type="file" name="image" id="image">
			</div>		
        </div>
      </div>
    </form>

And the Ajax POST method is:


	function save()
    {   
   
	  var url;
      url = "{{ URL::route('editor.data-wh.store') }}";
      
      $.ajax({
        type: 'POST',
        url: url,
        data: {
          'description': $('#description').val(), 
          'price': $('#price').val(),
		  'image': $('#image').val()
        },
		
        success: function(data) { 
		
		console.log(data);
            
             
          }
		}
	}

And here my controller:

  public function store(Request $request){

        // if request has file
        if($request->hasFile('image')){

            $filenameWithExt=$request->file('image')->getClientOriginalName();

            $filename=pathinfo($filenameWithExt,PATHINFO_FILENAME);

            $extension=$request->file('image')->getClientOriginalExtension();

            $fileNameToStore= date('mdYHis') . uniqid() .$filename.'.'.$extension;

            request()->image->move(public_path('img'), $fileNameToStore);  

     }else{
           $fileNameToStore='no-image.jpeg';
      }

  $post = new WhData(); 
  $post->description = $request->description;
  $post->price = $request->price;
  $post->image=$fileNameToStore;
  $post->save();
  return redirect()->back();
  }

But the data never save the uploaded image to the DB, the Database always stored no-image.jpeg (my else condition in controller) for image value. Here my form request in the Header request data in browser console:

description: Watermelon
price: 45
image: C:\fakepath\thumbnail.jpg

Almost 3 days now to solved this and look over the net too, but still no luck. Any idea how to solved this? Thanks,

Activity icon

Started a new Conversation Upload Image Over Javascript

I tried to make a laravel upload image with this controller:

public function addUser(Request $request){
       $user = new User();
       $user->lastName = $request->lastName;
       $user->firstName = $request->firstName;
       $user->email = $request->email;
       $user->login = $request->login;
       $user->password = bcrypt($request->password);

        if($request->image)
        {

          $original_directory = "uploads/users/";

          if(!File::exists($original_directory))
          {
            File::makeDirectory($original_directory, $mode = 0777, true, true);
          }

          $post->image = Carbon::now()->format("d-m-Y-h-i-s").$request->image->getClientOriginalName();
          $request->image->move($original_directory, $post->image);
          
        }
      $post->created_by = Auth::id();

      $post->save();

      return response()->json($post); 
 }

form in blade file (this is modal form):

<form enctype="multipart/form-data">
    <div class="form-group">
              <input type="text" id="lastName" class="form-control" placeholder="last Name" required />

            </div>
            <div class="form-group">
              <input type="text" id="firstName" class="form-control" placeholder="name" required />
            </div>
            <div class="form-group">
            <input type="email" id="email" class="form-control" placeholder="Email" required/>
            </div>
            <div class="form-group">
              <input type="text" id="login" class="form-control" placeholder="Login" required/>
            </div>
            <div class="form-group">
              <input type="password" id="password" class="form-control" placeholder="password" required/>
            </div>
            <div class="form-group">
               <input type="file" id="image" class="form-control"  required  />
            </div>
</form>

And the js script:

$(document).on('click', "#creer_utilisateur", function() {
    var lastName= $('#lastName').val();
    var firstName = $('#firstName').val();
    var email = $('#email').val();
    var login = $('#login').val();
    var password = $('#password').val();
    var image = $('#image').val();

        success: function(data) {
            $.ajax({
              url: "{{action('[email protected]')}}",
              method: 'POST',
              data: {
                lastName: lastName,
                firstName: firstName,
                email: email,
                login: login,
                password: password,
                image: image
              },
              success: function(data) {
			  console.log(data);
              alert('success');

              },
              error: function(){
                alert('failed');
              }
            });
        }
      });
  });

If I checked in the console log, the image form data never send. Anyone have advice how to solved this?

Thanks

Nov
26
3 months ago
Activity icon

Awarded Best Reply on Got Error BadMethod CallException Method

Solved. After rechecked my controller I found the same function name so the route only take a first one in order

Activity icon

Replied to Got Error BadMethod CallException Method

Thanks, for reply it solved now, I had a same function name in other controller.

Activity icon

Replied to Got Error BadMethod CallException Method

Solved. After rechecked my controller I found the same function name so the route only take a first one in order

Activity icon

Started a new Conversation Got Error BadMethod CallException Method

I got the following error BadMethod CallException Method does not exist, when access the page

my controller:

public function schedule_item(){
        $paired_schedules = $this->getSchedule_PC();
        return view('todo_schedule.schedule_item', compact('paired_schedules'));
    }

and the route:

Route::get('todo_schedules/schedule_item', '[email protected]_item')->name('todo_schedules.schedule_item');

Please help to solve this if anyone experienced with same issue?

Sep
26
5 months ago
Activity icon

Started a new Conversation Is It Possible To Convert Existing Web.php To Api.php (RESTFUL API)

I have a set of currently working routes on Laravel 5.6 (they are either called routes or web.php).

For example (web.php) route:

Route::group(['middleware' => ['auth', 'active']], function() {
	Route::post('sales/sale-data', '[email protected]');
	Route::post('api/sale-data', '[email protected]');
	Route::post('sales/sale-history', '[email protected]');
	Route::post('sales/sendmail', '[email protected]')->name('sale.sendmail');
	Route::get('sales/sale_by_csv', '[email protected]');
	Route::get('sales/product_sale/{id}','[email protected]');
});

I want to make RESTFUL API for scaling across different platforms. How do I convert my existing web.php into api.php? Is it possible? I tried to put this script on existing controller:

if ($request->wantsJson()) {

         return response()->json(['saleData' => $sales]);     

    }

and also tried this on controller:

		if (Request::is('api*')) {
			return response()->json($request->saleData());
		}else{
			echo json_encode($json_data);
		}

but it return not found.

and in my api.php route:

	Route::group(['middleware' => ['auth', 'active']], function() {
		Route::resource('api/sales/sale-data', 'SaleController');	
    });
Sep
20
5 months ago
Activity icon

Awarded Best Reply on Updating A Field On Another Table After Create Data In Laravel

Finally got it solved, maybe another user need it (newbie here)

$setBuilding = Building::updateOrCreate([
				'id' => $data['building_id'],
			], 
			[
				'user_id' => $data['user_id'],
			]);
Activity icon

Replied to Updating A Field On Another Table After Create Data In Laravel

Finally got it solved, maybe another user need it (newbie here)

$setBuilding = Building::updateOrCreate([
				'id' => $data['building_id'],
			], 
			[
				'user_id' => $data['user_id'],
			]);
Activity icon

Started a new Conversation Updating A Field On Another Table After Create Data In Laravel

Hello,

I want to create a function to insert the value from one table to another table after create. Currently I have a tables user and building. On my controller when creating the user need to select the building dropdown from building table. This will save data to user table with the building_id and also update the user_id field on building table. But I got stack for updating the building table with user_id value. Here my Usermodel:

public function ownbuilding()
    {
        return $this->hasMany('App\Building', 'user_id');
    }

and the building model is:

    public function user()
    {
        return $this->belongsTo('App\User', 'id');
    }

User controller:

......
User::create($data);
            $user = User::latest()->first();
            $data['user_id'] = $user->id;

$bd_id = $data['building_id'];
		$wh_user = $data['user_id'];
		$setBuilding->ownbuilding()->where('id', $wh_user)->update(['user_id' => $request->input('user_id')]);
.....

within this, I got the error message:

Call to a member function ownbuilding() on null

Also tried this one:

$setBuilding= Building::updateOrCreate(['user_id' => request()->$wh_user], [ 
			'user_id' => request()->$wh_user
		]);

No error appeared, but the user_id field not updated on Building table

Thanks for any suggestion :(

Sep
11
5 months ago
Activity icon

Started a new Conversation Anyone Has Experience Using Apiato?

Hi All,

Anyone here has experienced with apiato? I just want to know if possible to integrate apiato with the existing laravel system.

Thanks,