sadok

sadok

Member Since 1 Year Ago

Experience Points 250
Experience Level 1

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

27 May
11 months ago

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

@rin4ik that's true , i didn't remark that you changed the order. thank you very much, and thanks for all members for helping me and giving me many new informations that i can use in the future.

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

@rin4ik the problem is that Storage can't be found witch is not logic , that's so weird, it's driving me crazy

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

in postman i can see it returning the team id that i want to delete , but it doesn't get deleted

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

  public function destroy($id)
  {
    dd($id);
    $team=Team::findOrFail($id);
    $team->delete();
    \Storage::delete($team->logo);
    return response()->json(['data' => $team],200);
  }

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

it returns the team s id

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

no i checked my data base and the team still exists

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

yes i tried that still the same issue and i ve allready run the cmd php artisan storage:link and nothing of these tries solved my issue

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

i did try " use Storage " and it still returning 404 :(

sadok left a reply on Class 'App\Http\Controllers\Storage' Not Found

now it's returning 404

sadok started a new conversation Class 'App\Http\Controllers\Storage' Not Found

public function destroy($id)
  {
    $team=Team::findOrFail($id);
    $team->delete();
    Storage::delete($team->logo);
    return response()->json(['data' => $team],200);
  }
26 May
11 months ago

sadok started a new conversation Uploading An Image From Server

i'm using laravel in backend and react native in frontend i need some help to fix my backend code, please check the team creation code with me and tel me if there is any thing wrong:

public function create(Request $request){ $team = new Team; $team->name = $request->name; $team->category = $request->category; if($request->hasFile('logo')){ $team->logo = $request->logo->store('images'); } $team->responsable = $request->responsable; $team->club_id = $request->club_id; $team->save(); return response()->json(['data'=>$team],200); }

and here is my front end code witch is running correctly: import React, { Component } from 'react'; import { ScrollView, Text, View, TextInput, Button, ImageBackground, Image, TouchableOpacity } from 'react-native'; import { connect } from 'react-redux'; import Toast from 'react-native-simple-toast'; import ImagePicker from 'react-native-image-picker'; import { propertyAddTChanged, createTeam } from '../../../actions/TeamAction'; import { showClub } from '../../../actions/ClubAction'; import { Spinner } from './../../common/Spinner'; import { Headerr } from './../../common/Headerr';

class AddTeamScreen extends Component { componentWillMount() { const user_id = this.props.authStore.user.id; console.log('the users id', user_id); //const club_id = this.props.infoClubStore.club.id; this.props.showClub({ user_id }); //showClub function in Action console.log(this.props.infoClubStore); //this.props.showClub(); //console.log(club_id); }

selectPhotoTapped() { const options = { title: 'Take picture', cancelButtonTitle: 'cancel', takePhotoButtonTitle: 'take from camera', chooseFromLibraryButtonTitle: 'take fom gallery', quality: 1.0, maxWidth: 500, maxHeight: 500, storageOptions: { skipBackup: true } }; ImagePicker.showImagePicker(options, (response) => { if (response.didCancel) { console.log('User cancelled photo picker'); } else if (response.error) { console.log('ImagePicker Error: ', response.error); } else if (response.customButton) { console.log('User tapped custom button: ', response.customButton); } else { let source = { uri: response.uri }; const uri = response.uri; const value = response; this.props.propertyAddTChanged({ prop: 'photoUri', value }); // You can also display the image using data: // let source = { uri: 'data:image/jpeg;base64,' + response.data } this.setState({ avatarSource: source, }); this.setState({ data: uri, }); } }); }

Spinning() { if (this.props.teamCreationStore.loading || this.props.infoClubStore.loading) { return ( ); } else { return ( <Button onPress={() => { console.log('button hhh '); const club_id = this.props.infoClubStore.id; const name = this.props.teamCreationStore.name; const category = this.props.teamCreationStore.category; const photoUri = this.props.teamCreationStore.photoUri; const responsable = this.props.teamCreationStore.responsable; const nextDest = this.props.navigation;

      if (name === '') {
        return Toast.show('please name is required', Toast.LONG);
      }
      this.props.createTeam({ club_id, name, category, photoUri, responsable, nextDest });
    }
  }
    title="Submit"
    color="#00bfff"
  />
);

} }

renderLogoTeam(uri) { if ((uri !== null)) { return ( <Image style={{ borderRadius: 35, height: 70, width: 70, alignSelf: 'center' }} source={{ uri: uri.uri }} resizeMode="cover" /> ); } return (

 <Image
    source={require('../../../constants/images/cam.jpg')}
    style={{ height: 60, width: 60, alignSelf: 'center' }}
    resizeMode="cover"
 />

); }

render() { console.log(this.props); return ( <ImageBackground source={require('../../../constants/images/cr7.jpg')} //source={{ uri: ' ./img/std.jpg ' }} style={styles.backgroundImage} > <View style={{ flex: 1 }}>

    <ScrollView style={{ paddingTop: 10 }}>
    <View>
                    <TouchableOpacity onPress={this.selectPhotoTapped.bind(this)}>
                          <View>
                              {this.renderLogoTeam(this.props.teamCreationStore.photoUri)}
                          </View>
                    </TouchableOpacity>
                </View>
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <TextInput
        style={styles.inputStyle}
        placeholder='name'
        value={this.props.teamCreationStore.name}
        onChangeText={(text) => this.props.propertyAddTChanged({ prop: 'name', value: text })}
      />
      <TextInput
        style={styles.inputStyle}
        placeholder='category'
        value={this.props.teamCreationStore.category}
        onChangeText={value => this.props.propertyAddTChanged({ prop: 'category', value })}
      />
      <TextInput
        style={styles.inputStyle}
        placeholder='responsable'
        value={this.props.teamCreationStore.responsable}
        onChangeText={value => this.props.propertyAddTChanged({ prop: 'responsable', value })}
      />
      <TextInput
      style={styles.inputStyle}
      placeholder='logo'
      />

      { this.Spinning() }
      <Text>
        { this.props.teamCreationStore.error }
      </Text>
    </View>
  </ScrollView>
  </View>
  <Image
  source={require('../../../constants/images/bottomgreen.png')}
  style={styles.bottomImage}
  />
  </ImageBackground>
);

} }

// this function make us able to read the store whitch is registerStore const mapStateToProps = state => { return { teamCreationStore: state.teamCreationStore, clubStore: state.clubStore, infoClubStore: state.infoClubStore, authStore: state.authStore }; };

const styles = { textLoginStyle: { color: '#26A70F', fontSize: 55, fontStyle: 'italic', fontWeight: 'bold', textDecorationLine: 'underline', textShadowRadius: '55' }, backgroundImage: { flex: 1, width: '100%', height: '100%', //resizeMode: 'cover' only in Image not BackgroundImage ! }, inputStyle: { color: 'black', fontSize: 25, fontWeight: 'bold', borderWidth: 1, borderRadius: 10, borderColor: '#48BBEC', //backgroundColor: '#DA5561', width: 320, paddingTop: 15, }, bottomImage: { position: 'absolute', bottom: 0, width: '100%', height: 50, }, };

export default connect(mapStateToProps, { propertyAddTChanged, createTeam, showClub })(AddTeamScreen);

14 Mar
1 year ago

sadok left a reply on Eloquent Relationships

thnx this was really helpful

13 Mar
1 year ago

sadok started a new conversation Eloquent Relationships

i'm receiving this error when i do the php artisan migrate command, Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table abab.#sql-13ac_dc (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table users add constraint users_match_id_foreign foreign key (match_id) references matches (id))

public function up() { Schema::create('matches', function (Blueprint $table) { $table->increments('id')->unsigned()->unique(); $table->integer('user_id')->unsigned()->unique(); $table->timestamps(); $table->DateTime('game_date'); $table->string('stadium'); $table->string('competition'); }); Schema::table('matches', function (Blueprint $table) { $table->foreign('user_id')->references('id')->on('users'); }); }

public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id')->unsigned()->unique(); $table->integer('match_id')->unsigned()->unique(); $table->string('name'); $table->string('email')->unique(); $table->string('password')->bcrypt('secret'); $table->string('gender'); $table->DateTime('birthday'); $table->rememberToken(); $table->timestamps(); }); Schema::table('users', function (Blueprint $table) { $table->foreign('match_id')->references('id')->on('matches'); }); }

Models: class User extends Authenticatable { use Notifiable;

protected $fillable = [
    'match_id', 'name', 'email', 'password','gender','birthday',
];

public function matches(){
  return $this.hasMany('App\Match','match_id'); // ou bien $this->hasMany(Match::class);
}

protected $hidden = [
    'password', 'remember_token',
];

}

class Match extends Model { use Notifiable;

    protected $fillable = [
        'user_id', 'game_date', 'stadium', 'competition'
    ];

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

    protected $hidden = [
       'remember_token',
    ];

}

any help plz